Forum > Graphics

Problem reload an icon to TIcon

(1/1)

Peiman:
Hi!

Bellow, is what i've written to load several icons to a TIcon with TIcon.LoadFromFile and to save them into .bmp files.

for i := 0 to N do
  begin
  Icon.LoadFromFile(Strings);
  BitBlt(Bmp.Canvas.Handle,0,0,31,31,Icon.Canvas.Handle,
          0,0,SRCCOPY);
  Bmp.SaveToFile(Strings+'.bmp');
  end;

The problem is that all of the bitmap file saved only contain the first icon (i=0). What is the problem? I even used to create and destroy the Icon inside the loop, but no change.

felipemdc:

--- Quote from: Peiman on December 09, 2009, 05:40:02 pm ---The problem is that all of the bitmap file saved only contain the first icon (i=0). What is the problem?
--- End quote ---

But your code does exactly this ... it draws the first image in the icon.

Do you want to draw all images from the icon to the bitmap? In which positioning?

You need to create a loop which iterates through all images in the icon, you can use the property TIcon.Current, TIcon.Width and TIcon.Count for that if I remember well, and paint them all, in the positioning that you want.

Navigation

[0] Message Index

Go to full version