Export Image from GdPicture to a TImage Delphi object

Discussions about image processing and document imaging.
Post Reply
Slava
Posts: 66
Joined: Fri Jun 22, 2007 4:43 pm

Export Image from GdPicture to a TImage Delphi object

Post by Slava » Wed Jun 27, 2007 11:12 am

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

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Post by Loïc » Wed Jun 27, 2007 11:43 am

Hi,

You can do like that:

Code: Select all

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

Best regards,

Loïc Carrère

Slava
Posts: 66
Joined: Fri Jun 22, 2007 4:43 pm

Post by Slava » Wed Jun 27, 2007 12:42 pm

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

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Post by Loïc » Wed Jun 27, 2007 1:56 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest