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 : Friday, March 30, 2007 6:36:21 AM(UTC)

sfirouz  
sfirouz

Groups: Registered
Posts: 6


Hi:
I have a bitmap in the resource which I can load into memory using the Windows API calls like:

HBITMAP thumbLoad = NULL;
thumbLoad = LoadBitmap(ImageEditorInstance, "ThumbLoad");

How can I convert this to TLEADImage (VCL). I am willing to use the LeadTools API calls if I have to.
I am using version 14.0

Thank you
Sam
 

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 : Sunday, April 1, 2007 11:29:43 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

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

Hello,

The bitmap returned by the Windows API LoadBitmap function is a Device Dependent Bitmap. You should be able to assign it to a LEAD bitmap using the Main VCL SetDDB function.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, April 2, 2007 4:09:23 AM(UTC)

sfirouz  
sfirouz

Groups: Registered
Posts: 6


Is there a DIB version of LoadBitmap that I can use?
 
#4 Posted : Monday, April 2, 2007 6:45:31 AM(UTC)

sfirouz  
sfirouz

Groups: Registered
Posts: 6


ok here is what I did:

HANDLE tBmpHandle;

tBmpHandle = LoadImage(MainInstance, "TestBmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_MONOCHROME);
try
{
Image->SetDIB((unsigned int)tBmpHandle);
}
__finally
{
DeleteObject(tBmpHandle);
}

But I get "SetDIB:Invalid parameter passed." error.

Thank you
Sam
 
#5 Posted : Tuesday, April 3, 2007 10:03:04 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

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

Hello,

Are you sure that the tBmpHandle contains valid image data?
Also, if declare the tBmpHandle as THandle and pass it as follows, do you get the same problem?
Image->SetDIB(tBmpHandle)

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#6 Posted : Monday, April 9, 2007 8:57:25 AM(UTC)

sfirouz  
sfirouz

Groups: Registered
Posts: 6


As you can see in the attached test project, the bitmap is valid and using THandle will not have any effect.
File Attachment(s):
LeadTools.zip (6kb) downloaded 29 time(s).
 
#7 Posted : Thursday, April 12, 2007 5:00:24 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

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

Hello,

The SetDIB function requires an HGLOBAL. One way to load the resource and set it is:
HRSRC pResrce = FindResource(NULL, "TestBmp", RT_BITMAP);
int n=SizeofResource(NULL, pResrce);
HGLOBAL hResBitmap = GlobalAlloc(0, n);
void *p=GlobalLock(hResBitmap);
memcpy(p, LoadResource(NULL,pResrce), n);
GlobalUnlock(hResBitmap);
LEADImage1->SetDIB((unsigned int)hResBitmap);
GlobalFree(hResBitmap);

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
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.202 seconds.