Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, December 9, 2004 2:26:39 AM(UTC)
ruvinsky

Groups: Registered
Posts: 2


how can i send the image contained in a TLEADImage component into a TImage or TPicture

standart Delphi components

thanks

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, July 20, 2005 7:16:11 AM(UTC)

Otis  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

Thank you for contacting LEADTOOLS. You can use the GetDIB method to convert the LEAD image to a Windows device independent bitmap (DIB). This method will give you a handle that you can use for your TImage or TPicture.

 

 
#3 Posted : Wednesday, September 21, 2005 4:56:15 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Hi,

i also tried to convert a LeadImage to TImage, but i didn't find any solution. (except using clipboard)
I tried to use GetDIB method, and when i assign the handle to the TImage.Picture.Bitmap.Handle , it displays nothing.
But GetDIB method works well between 2 TLeadImage.

Do i missed something ?

Thanks in Advance.
 
#4 Posted : Monday, September 26, 2005 1:24:30 PM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 356


One way to convert a LEAD 14 VCL bitmap to a TImage object named Image1, is to use the following code
Image1.Picture.Bitmap.width := LeadImage1.BitmapWidth;
Image1.Picture.Bitmap.Height := LeadImage1.BitmapHeight;
LeadImage1.RenderCenter := False;
LeadImage1.Render(Image1.Picture.Bitmap.canvas.handle, 0, 0, LeadImage1.BitmapWidth, LeadImage1.BitmapHeight);

Amin Dodin

LEADTOOLS Technical Support
Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#5 Posted : Thursday, September 29, 2005 12:57:05 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Thanks,

This way seems a good solution, except that i get an error with the Render function, i get the message "Image not allocated".

Do i have to load an image before using Render function ? This would be strange, because i want to to load the LeadImage with the TImage..

Is there a way for initializing the TLeadImage in order to use the render function ?

Thanks,

Julien Lefranc

 
#6 Posted : Sunday, October 2, 2005 3:15:34 PM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 356


Julien,

In your previous post, you wrote "convert a LeadImage to TImage". In
that case, you should already have a valid LeadImage to use the code I posted last time.

If you want to do the opposite, which is converting a Borland TImage to a TLeadImage, use this code instead:
LEADImage1.FromHBitmap(Image1.Picture.Bitmap.Handle, Image1.Picture.Bitmap.Palette);

Where Image1.Picture.Bitmap has a valid Windows bitmap in it.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#7 Posted : Sunday, October 2, 2005 11:35:16 PM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Thanks,

This works perfectly now.

 
#8 Posted : Wednesday, June 7, 2006 5:26:48 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Hi Again,

Converting TLeadImage to TImage works well with this method :

Image1.Picture.Bitmap.width := LeadImage1.BitmapWidth;
Image1.Picture.Bitmap.Height := LeadImage1.BitmapHeight;
LeadImage1.RenderCenter := False;
LeadImage1.Render(Image1.Picture.Bitmap.canvas.handle, 0, 0, LeadImage1.BitmapWidth, LeadImage1.BitmapHeight);

But if i work with a big LeadImage (7000 x 5000), this procedure raise an exception on the second line... Exeption "EOutOfResources"...
it seems that a TBitmap don't like big width and height size...

Do someone have an idea ?

Thanks.

 
#9 Posted : Sunday, June 11, 2006 8:20:56 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 356


Julien,
If the error occurs at line 2, which merely sets the bitmap's height, I'm afraid you have little hope of using Image1.Picture.Bitmap with such a large image. What you're doing in the first 2 lines is only allocating the image storage area. If that fails, you won't have a valid bitmap to continue with.
There could be a different way to achieve the end result using LEADTOOLS alone without having to convert to Image1.Picture.Bitmap. If you give me more details why you need the conversion, I might be able to suggest something.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#10 Posted : Monday, June 12, 2006 5:01:10 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Hi,

i try to convert the LeadImage to TImage in order to send the image into my DataBase in a blob field.

Using LeadTools with database storage is not so easy i believe.

I manage using clipboard, but not a good solution for me.

Thanks.

 
#11 Posted : Tuesday, June 13, 2006 11:30:38 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 356


Julien,
Our main VCL control supports data binding. There is a tutorial in the help file titled "Using LEADTOOLS with Data Controls (Delphi)" that shows how to do that.
If this approach doesn't work in your case, you could try to save the image into a memory buffer using the SaveMemory or SaveBuffer methods, then store the memory buffer into the database. To load from the database, you need to retrieve the BLOB into a memory buffer, then use the LEAD LoadMemory method with that buffer.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#12 Posted : Wednesday, June 14, 2006 12:18:47 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Hi Amin,

the first approach doesn't fit to me. The second sounds good. I manage to save the image into memory using SaveMemory method. But how can i send the buffer into the database ? i use SLQDataset from delphi, how can i affect the buffer into a Blob parameter ?

do i have to create a memorystream, or else ?

Thanks.

 
#13 Posted : Thursday, June 15, 2006 4:54:53 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 356


Julien,
Can you use the LoadFromStream method (TBlobField) if the data is in a MemoryStream?
If yes, you can try using the Write method (TMemoryStream) to copy the memory contents from the buffer saved by the LEAD SaveMemory method to the MemoryStream.
Don't forget to free the buffer to avoid memory leaks.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#14 Posted : Thursday, June 15, 2006 5:37:39 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Hi Amin,

yes i can use the loadfromstream method with a memorystream. I Manage to save the LeadImage in memory with SaveMemory method but when i try to write in the MemoryStream i get an access violation... here is the code :

JPEGMS : TMemoryStream;                                                                                 

hMem     : L_HANDLE;

JPEGMS : TMemoryStream.Create;

LeadImg1.SaveMemory(hMem,FILE_JFIF,LeadImg1.infoBits,80,iSize);
LeadImg1.GetMemoryInfo(hMem,0,iSize);

JPEGMS.Write(hMem,iSize);

I also tried LEADImage.SaveBuffer method, but i also get an access violation on the MemoryStream.Write method. Maybe thr hMem type doesn't fit... Do you have an idea ?

Thanks

 

 

 
#15 Posted : Monday, June 19, 2006 9:19:53 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 356


Julien,
It seems the TMemoryStream.Write method needs the address of the first byte of the buffer. Here's a working code sample:

JPEGMS : TMemoryStream;
hMem   : L_HANDLE;
pMem   : PChar;
iSize  : Integer;

LEADImage1.load('11.jpg', 24, 1, 1);
JPEGMS := TMemoryStream.Create;
LEADImage1.SaveMemory(hMem, FILE_JFIF, LEADImage1.infoBits, 80, iSize);
LEADImage1.GetMemoryInfo(hMem, 0, iSize);
pMem := GlobalLock(hMem);
JPEGMS.Write(pMem[0],iSize);
GlobalUnlock(hMem);
GlobalFree(hMem);
JPEGMS.SaveToFile('fromVCLMemStream.jpg'); // use your database code instead.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#16 Posted : Monday, June 26, 2006 12:24:41 AM(UTC)
julien.lefranc

Groups: Registered
Posts: 17


Hi Amin,

you're absolutely right, giving the first byte of the buffer to the TMemoryStream.Write method works fine.

Thank you very much for your help.

 

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.116 seconds.