Loading specific icon size into TIcon from stream (Delphi XE)
Posted
by
moodforaday
on Stack Overflow
See other posts from Stack Overflow
or by moodforaday
Published on 2011-01-04T00:35:21Z
Indexed on
2011/01/04
0:53 UTC
Read the original article
Hit count: 273
My application downloads and displays favicons for specific websites. I followed Bing's solution for detecting image format from stream, but have hit another snag. Assuming an actual icon image, the code goes like this:
var
icon : TIcon;
begin
icon := TIcon.Create;
try
icon.LoadFromStream( faviconStream );
spFavicon.Glyph.Assign( icon );
finally
icon.Free;
end;
end;
(spFavicon is TRzGlyphStatus from Raize Components. Its Glyph property is a TBitmap)
Now, this works, but sometimes the downloaded icon contains multiple images in different sizes, e.g. 32x32 in addition to the expected 16x16. For some reason the control's Glyph property picks the larger size.
How can I load only the 16x16 size into TIcon, or from TIcon into TBitmap?
Test favicon: http://www.kpfa.org/favicon.ico
On edit: If at all possible, I'd rather avoid saving the icon to a file first.
© Stack Overflow or respective owner