Page 1 of 1

Export Image from GdPicture to a TImage Delphi object

Posted: Wed Jun 27, 2007 11:12 am
by Slava
Hello,

I am trying to create thumbnails from all the files in a folder with Delphi 7. I achieved this by creating GdViewer for each thumbnail but its slow and unnessesary.

i would like to know if it is possible to get a bitmap (in runtime) out of GdViewer/GdPicture when an image is loaded, to put in standard image components like TImage.

I mean something like
TImage.Bitmap := GdViewer.GetBitmap
would be great but there's no bitmap, GetNativeImage returns an Integer, gdpicture.GetPicture returns IPictureDisp ?, even gdpicture.GetHBitmap returns an integer.

if this cannot be done, is there other way to create thumbnails? (I have seen a VB example, cannot understand why ImageList1.ListImages.Add(... , oGdPicture.GetPicture, ...) works, because it doesnt in Delphi, saying "Incompatible Types: TBitmap and IPictureDisp".

Anyone?

Slava

Posted: Wed Jun 27, 2007 11:43 am
by Loïc
Hi,

You can do like that:

Code: Select all

Image1.Picture.Bitmap.Handle:=oGdPicture.GetHBitmap;

Best regards,

Loïc Carrère

Posted: Wed Jun 27, 2007 12:42 pm
by Slava
Loïc wrote: You can do like that:

Code: Select all

Image1.Picture.Bitmap.Handle:=oGdPicture.GetHBitmap;
Really simple, and works. Thanks. Quick respond, thanks again.

One more question, this dont seem to work:

Code: Select all

imgThumb.Picture.Bitmap.Handle := oGdPicture.MakeThumbnail( ... );
Should it work? or do i have to use oGdPicture.Resize and oGdPicture.GetHBitmap?

Slava

Posted: Wed Jun 27, 2007 1:56 pm
by Loïc
Hi,

MakeThumbnail returns a gdiplus image handle, not a HBtimap.

You can do something like that:

Code: Select all

nNativeImage:= oGdPicture.GetnativeImage;
oGdPicture.SetNativeImage( oGdPicture.MakeThumbnail( 200,200));
Image1.Picture.Bitmap.Handle:=oGdPicture.GetHBitmap;
oGdPicture.SetNativeImage(nNativeImage);
Best regards,

Loïc Carrère