Entwickler-Ecke

Multimedia / Grafik - Problem bei konvertierung von BitMap zu Icon


MrKnogge - Fr 24.01.03 19:30
Titel: Problem bei konvertierung von BitMap zu Icon
Hi

da man in den Delph-Menüs leider nur BitMaps benutzen kann, wollt ich einen kleinen konverter schreiben der Icon´s in BitMaps kovertiert und umgekehrt.

Das von Icon nach BitMap klappt bereits.

Nur andersrum habe ich das Problem, das das Icon invertiert ist, also immer so als ob es markiert wäre, wenn ich es markiere ist es so wie ichs will.


Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
begin 
pathload := LWL+DNL+'.bmp'; 
pathsave := LWS+DNS+'.ico'; 
IconX := GetSystemMetrics(SM_CXICON); 
IconY := GetSystemMetrics(SM_CYICON); 
Icon := TIcon.Create; 
Bitmap := TBitmap.Create; 
Mask := TBitmap.Create; 
BitMap.Width:=IconX; 
BitMap.Height:=IconY; 
Mask.Width:=IconX; 
Mask.Height:=IconY; 
Mask.Monochrome:=true; 
Bitmap.LoadFromFile(pathload); 
Mask.LoadFromFile(pathload); 

with iconinfo do begin 
  fIcon:=true; 
  xHotspot:=0; 
  yHotspot:=0; 
  hbmMask:=Mask.Handle; 
  hbmColor:=BitMap.Handle; 
  end; 

Icon.Handle:=CreateIconIndirect(IconInfo); 
Icon.SaveToFile(pathsave); 
Icon.Free; 
Bitmap.Free; 
Mask.Free; 

end;


Andreas Pfau - Fr 24.01.03 19:38

Probier mal, "Mask.Monochrome" nach "Mask.LoadFromFile()" zu setzen, dann ist Mask auf jeden Fall Monochrom.