Reputation: 2797
I want to save an ico from db to file, but I have a problem with transparency. When I save it to c:\1.ico, the result file does have no transparency.
procedure DBIconsToFIle;
var
Streams: TStream;
fIcon : TBitmap;
begin
//load stream from db
FIcon.LoadFromStream(Streams);
FIcon := TBitmap.Create;
FIcon.TransparentColor := clWhite;
FIcon.PixelFormat := pf32bit;
FIcon.Height := 16;
FIcon.Width := 16;
FIcon.SaveToFile(tmpFile);
//destroys
end;
How I can save it with transparency?
Upvotes: 0
Views: 1631
Reputation: 109158
The filename extension for icons is .ico, not .icon. Also, why don't you use TIcon
instead of TBitmap
if you want to save an icon? And why in the world do you use LoadFromStream
first and TBitmap.Create
second?!
Does the slightly more normal code
var
Icon: TIcon;
begin
Icon := TIcon.Create;
try
Icon.LoadFromStream(SomeStream);
Icon.SaveToFile(SomeFileName);
finally
Icon.Free;
end;
work for you?
Upvotes: 3