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 : Sunday, January 5, 2014 1:53:20 PM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


I’m using LeadTools Raster Imaging Pro v14.
But there are some problems with LeadTools.

1.I tried to display the PNG file with black transparent background, but it displayed all black image.

The image that I use has black transparent background and 32 bits per pixel.

- In my program, I read file information using L_FileInfoMemory in ltfil14n.dll. After reading this image, it's BitsPerPixel of FILEINFO is 24 bits.
- I get BITMAPHANCLE's information using L_InitBitmap in ltkrn14n.dll but Transparency value is FALSE.
- I draw PNG file using L_PaintDC in ltdis14n.dll.

How to draw image with black transparent background.


2.
But when image is scaled(zoomed out), the clarity of image is decrease.
When I use DISPLAYMODE_BICUBIC option as parameter of SetDisplayMode function, JPG and GIF image are kept the clarity of image but PNG, BMP, TIF, PCX image’s clarity is decrease.

Sample image: 125.129.124.44/report/hjlee/is.png
Original sample image used: 125.129.124.44/report/hjlee/01_1.png

BPP(bits per pixel) of PNG images is 1.
BPP(bits per pixel) of JPG images is 24.
BPP(bits per pixel) of BMP images is 1.
BPP(bits per pixel) of GIF images is 8.
BPP(bits per pixel) of TIF images is 1.

How to increase the clarity of images?
 

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 : Monday, January 6, 2014 5:56:34 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


Hjleesm,
What do you mean by PNG file with black transparent background? Do you mean that the alpha channel is black (transparent)? Or do you mean the PNG file has a single-color transparent?
Please note that you should get the transparency value from the BITMAPHANDLE immediately after loading the image, not after initializing it.

If you still can't get it to work, please send me the PNG file that shows the problem and explain more about the problem.

Also, what are the DLLs "file version" (from the file's properties dialog) of ltkrn14n.dll, ltfil14n.dll and ltdis14n.dll that you have? It should be something like 14.x.0.xx/

If you are going to upload the image here, please put it inside ZIP or RAR file to ensure that it is delivered correctly and do NOT use "Preview" option.

About the second issue, it appears that all images which are losing clarity are 1-bit images but DISPLAYMODE_BICUBIC does  not work with 1-bit images.
Owners of Document or Medical toolkits can use the DISPLAYMODE_SCALETOGRAY with 1-bit black and white images.

Since you only have Raster Imaging Pro, you cannot use this display mode, but you can change the image to 8-bit grayscale using L_GrayScaleBitmap() function, then use the DISPLAYMODE_RESAMPLE or DISPLAYMODE_BICUBIC flag.

 
#3 Posted : Wednesday, January 8, 2014 9:38:20 PM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


I don't know that it's alpha channel is black or PNG file has a single-color transparent.
so, I uploaded that PNG file (sample png.zip).

DLLs files's version is '14.5.0.77'
File Attachment(s):
sample png.zip (1kb) downloaded 53 time(s).
 
#4 Posted : Thursday, January 9, 2014 12:21:19 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


This image is a 32-bit image with Alpha channel. I have loaded the image into our Main CDLL v18 demo and separated the alpha channel and verified that (see attached screenshot).

Are you still getting the image as black even after getting the transparency value from the BITMAPHANDLE immediately after loading the image, not after initializing it?

If yes, what is the code that you are using to do this? Also, the DLLs that you have are NOT the latest build. The latest version for Ltkrn14n.dll is 14.5.0.82. You should test the same issue using the latest DLLs, to get the latest LEADTOOLS v14.5 DLLs, send an email to support@leadtools.com and include the following information:
1) Your toolkit's serial number (do NOT post here)
2) A link to this forum post.

Daoud attached the following image(s):
screenshot.png
 
#5 Posted : Sunday, January 12, 2014 3:08:54 PM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


we draw images in our program as below.

Because m_RImage.Flags.Transparency is false, so we don't use L_SetBitmapRgnColor function.

BYTE *pgifbuf;
BITMAPHANDLE m_RImage;
//pgifbuf : image byte array
FILEINFO FileInfo;
memset(&FileInfo, 0, sizeof(FILEINFO));
FileInfo.uStructSize = sizeof(FILEINFO);

L_FileInfoMemory (pgifbuf, &FileInfo, sizeof(FILEINFO), len, 0, NULL);
L_InitBitmap (&m_RImage, sizeof(BITMAPHANDLE), FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel);
memset(&LoadFileOption, 0, sizeof(LOADFILEOPTION));
L_GetDefaultLoadFileOption (&LoadFileOption, sizeof(LOADFILEOPTION));
L_LoadBitmapMemory (pgifbuf, &m_RImage, sizeof(BITMAPHANDLE), FileInfo.BitsPerPixel,
ORDER_BGR, len, &LoadFileOption, &FileInfo);

L_CreatePaintPalette (hDC, &m_RImage);
ulFlags = L_GetDisplayMode ();
L_SetDisplayMode(DISPLAYMODE_RESAMPLE|DISPLAYMODE_BICUBIC, DISPLAYMODE_BICUBIC);
L_PaintDC (hDC,&m_RImage, &rcSrc, &rcSrc, &rcDest, &rcDest,SRCCOPY);
L_SetDisplayMode (DISPLAYMODE_RESETPOSITIONS, ulFlags);



we want the sample code to draw images with Alpha channel.
 
#6 Posted : Monday, January 13, 2014 8:12:37 PM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


If you're dealing with images like the sample you sent, which is already 32-bit and has an Alpha transparency channel, you can paint it in LEADTOOLS 14 as follows:
1. Load it as 32-bit
2. Extract the alpha channel into a separate grayscale bitmap using the L_GetBitmapAlpha() function.
3. Load or create a suitable background image.
4. Mix all 3 images (main, alpha and background) using the L_AlphaBlendBitmap().

In the current version of LEADTOOLS, you don't need all these steps because you can use GDI+ for painting, which automatically considers the alpha channel for transparency. However, that feature was not available in LEADTOOLS 14.x.

 
#7 Posted : Monday, January 20, 2014 6:49:55 PM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


I tried to dealing with my image as your guide. But image is displayed like image in atteched file.
Is there something not right in my source code?

// 1. Load it as 32-bit
//m_RImage is loaded image.

//2. Extract the alpha channel into a separate grayscale bitmap using the L_GetBitmapAlpha() function.
BITMAPHANDLE m_AImage = {0}; //Alpha image
L_GetBitmapAlpha(&m_RImage, &m_AImage, sizeof(BITMAPHANDLE));

//3. Load or create a suitable background image.
BITMAPHANDLE BackgroundBmp = {0};
L_CopyBitmap(&BackgroundBmp, &m_RImage, sizeof(BITMAPHANDLE));
L_FillBitmap(&BackgroundBmp, RGB(255, 255, 255));

//4. Mix all 3 images (main, alpha and background) using the L_AlphaBlendBitmap().
L_AlphaBlendBitmap(&BackgroundBmp, 0, 0, BITMAPWIDTH(&m_RImage), BITMAPHEIGHT(&m_RImage), &m_AImage, 0, 0, 128, 0);
L_AlphaBlendBitmap(&m_RImage, 0, 0, BITMAPWIDTH(&m_RImage), BITMAPHEIGHT(&m_RImage), &BackgroundBmp, 0, 0, 128, 0);
hjleesm attached the following image(s):
why1.png
 
#8 Posted : Tuesday, January 21, 2014 6:23:53 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


For the first call to L_AlphaBlendBitmap() make the opacity 255, and set it to 0 for the second one.
Here is my code below:
===============================
L_INT nRet=0;
BITMAPHANDLE LeadBitmap={0};
BITMAPHANDLE AlphaBitmap={0};
BITMAPHANDLE BackgroundBmp = {0};
FILEINFO info={0};
nRet=L_FileInfo(TEXT("D:\\delme\\OLEE12E.png"),&info,sizeof(FILEINFO),FILEINFO_TOTALPAGES,NULL);
nRet=L_LoadBitmap (TEXT("D:\\delme\\OLEE12E.png"), &LeadBitmap, sizeof(BITMAPHANDLE),0, ORDER_BGR, NULL, NULL);
nRet=L_GetBitmapAlpha(&LeadBitmap,&AlphaBitmap,sizeof(BITMAPHANDLE));
L_CopyBitmap(&BackgroundBmp, &LeadBitmap, sizeof(BITMAPHANDLE));
L_FillBitmap(&BackgroundBmp, RGB(255, 255, 255));
nRet=L_AlphaBlendBitmap(&BackgroundBmp, 0, 0, BITMAPWIDTH(&LeadBitmap), BITMAPHEIGHT(&LeadBitmap), &AlphaBitmap, 0, 0, 255);
nRet=L_AlphaBlendBitmap(&LeadBitmap, 0, 0, BITMAPWIDTH(&LeadBitmap), BITMAPHEIGHT(&LeadBitmap), &BackgroundBmp, 0, 0, 0);
===============================

 
#9 Posted : Tuesday, January 21, 2014 3:58:38 PM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


I tried to draw image as your guide.

For the first call, I set the opacity to 255, and set it to 0 for the second one.

L_AlphaBlendBitmap(&BackgroundBmp, 0, 0, BITMAPWIDTH(&m_RImage), BITMAPHEIGHT(&m_RImage), &m_AImage, 0, 0, 255, 0);
L_AlphaBlendBitmap(&m_RImage, 0, 0, BITMAPWIDTH(&m_RImage), BITMAPHEIGHT(&m_RImage), &BackgroundBmp, 0, 0, 0, 0);

but it displayed all black image.

Is there anything else I set?
 
#10 Posted : Wednesday, January 22, 2014 10:53:09 PM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


If you try the exact same code and only modify the file loading path, do you still get the problem?
Also, I noticed that your code contains 10 parameters but I can only find one overload that has 9 parameters. Did you update the DLLs, Libs and header files with the new ones from the patch I sent you instructions to download?

You also can try using L_FeatherAlphaBlendBitmap() which will give you the same results. The following code shows you how:
=======================================
L_INT nRet=0;
BITMAPHANDLE LeadBitmap={0};
BITMAPHANDLE AlphaBitmap={0};
BITMAPHANDLE BackgroundBmp = {0};
FILEINFO info={0};
nRet=L_FileInfo(TEXT("D:\\test\\OLEE12E.png"),&info,sizeof(FILEINFO),FILEINFO_TOTALPAGES,NULL);
nRet=L_LoadBitmap (TEXT("D:\\test\\OLEE12E.png"), &LeadBitmap, sizeof(BITMAPHANDLE),0, ORDER_BGR, NULL, NULL);
nRet=L_GetBitmapAlpha(&LeadBitmap,&AlphaBitmap,sizeof(BITMAPHANDLE));
L_CopyBitmap(&BackgroundBmp, &LeadBitmap, sizeof(BITMAPHANDLE));
L_FillBitmap(&BackgroundBmp, RGB(0, 0, 0));
L_FeatherAlphaBlendBitmap(&LeadBitmap,0,0,BITMAPWIDTH(&LeadBitmap), BITMAPHEIGHT(&LeadBitmap),&BackgroundBmp,0,0,&AlphaBitmap);
nRet=L_SaveBitmap(TEXT("D:\\test\\FEATHER_RESULT.png"),&LeadBitmap,FILE_PNG,32,0,NULL);
=======================================

Attached are the result images I got for both L_AlphaBlendBitmap() and L_FeatherAlphaBlendBitmap() calls.
Please ntoe that L_FeatherAlphaBlendBitmap() also takes 9 parameters.

If you still face problems, please provide me with the following:
1) A small sample project (NOT your full application) that shows the issue and put it inside ZIP or RAR file.
2) The exact steps I need to take to reproduce the issue at my end.
3) What is the Windows version (XP, Vista, 7..etc) that you are seeing the issue on?
4) Which visual studio are you using (2008,2010..etc)?

NOTE: Put all attachments inside ZIP or RAR file and do NOT use "Preview" option.

File Attachment(s):
resulting_images.zip (3kb) downloaded 47 time(s).
 
#11 Posted : Tuesday, January 28, 2014 4:31:30 AM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


I tried to use L_FeatherAlphaBlendBitmap() function in your DEMO Program. The image is displayed correctly.

So I tried to use L_FeatherAlphaBlendBitmap() function in my program.

But in my program L_FeatherAlphaBlendBitmap() returned a error code(-930).

I know our license is pro version.
 
#12 Posted : Tuesday, January 28, 2014 5:13:45 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


This error means "LEADTOOLS Pro Features are not enabled". L_FeatherAlphaBlendBitmap is included with LEADTOOLS Raster Pro and above toolkits. To use it, you will need to use Ltkrn14*.dll inside [LEADTOOLS 14.5]\Redist\NONAG and in your application before calling any of LEADTOOLS features, you need to call L_UnlockSupport () and pass to it your Raster Pro key.
 
#13 Posted : Tuesday, January 28, 2014 3:12:06 PM(UTC)

hjleesm  
hjleesm

Groups: Registered
Posts: 8


There are 2 parameter in L_UnlockSupport function.
To use R_FeatherAlphaBlendBitmap() function, what value should I pass as 1st parameter?
And as 2nd parameter should I pass my SDK Serial Number?
 
#14 Posted : Wednesday, January 29, 2014 12:31:15 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


The first parameter is for the feature you want to unlock such as "L_SUPPORT_LTPRO", which unlocks support for advanced image processing functions only available in the Raster Pro and above toolkits (which includes L_FeatherAlphaBlendBitmap).

The second parameter, is for the unlock key for that feature. This is the key you received from our sales team.
If you don't have it, contact sales@leadtools.com to request it.

For more information about L_UnlockSupport() and its parameters, see the our documentation for this function.

 
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-2024, Yet Another Forum.NET
This page was generated in 0.161 seconds.