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 : Tuesday, March 19, 2013 11:02:33 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


Hi,

We are currently trying to display PNG / BMP images with alpha channels using the ff code. Based on the debugging info, fileinfo.Flags has FILEINFO_HAS_ALPHA and hLeadBitmap.Flags.Transparency always returns 0. The resulting image however is that the surrounding area of the image is black. I have attached a couple of files for testing.

RedirectIO(OpenPicFiles, NULL, NULL, NULL, NULL, (L_VOID *)filename) ;

Ret = FileInfo(filename, &fileinfo, sizeof(FILEINFO), 0, NULL);
if( Ret == SUCCESS && fileinfo.Flags & FILEINFO_HAS_ALPHA ){ // check to make sure that it has alpha channels
    . . .
} // if
Ret = InitBitmap(&hLeadBitmap, sizeof(BITMAPHANDLE), fileinfo.Width, fileinfo.Height, fileinfo.BitsPerPixel);
Ret = LoadBitmap(filename, &hLeadBitmap, sizeof(BITMAPHANDLE), hLeadBitmap.BitsPerPixel, hLeadBitmap.Order, NULL, NULL);
// debugging hLeadBitmap.Flags.Transparency, always returns 0

RedirectIO(NULL, NULL, NULL, NULL, NULL, NULL) ;

w_DispModeType = GetDisplayMode() ;
SetDisplayMode(DISPLAYMODE_FIXEDPALETTE|DISPLAYMODE_RESAMPLE|DISPLAYMODE_BICUBIC, DISPLAYMODE_FIXEDPALETTE|DISPLAYMODE_BICUBIC);
hpalPaint = CreatePaintPalette(dc.GetSafeHdc(), &hLeadBitmap);
if (hpalPaint)
{
SelectPalette (dc.GetSafeHdc(), hpalPaint, FALSE);
RealizePalette (dc.GetSafeHdc());
}
PaintDCEffect(dc.GetSafeHdc(), &hLeadBitmapNULL, NULL, &DrawRect, PaintRect, SRCCOPY, 0);
SetDisplayMode(DISPLAYMODE_FIXEDPALETTE|DISPLAYMODE_BICUBIC|w_DispModeType, w_DispModeType) ;
 

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 : Tuesday, March 19, 2013 11:07:35 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


We are currently using LEADTOOLS Raster Imaging Pro version 15.0 toolkit.
 
#3 Posted : Tuesday, March 19, 2013 11:09:09 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


We are currently using LEADTOOLS Raster Imaging Pro version 15.0 toolkit.
 
#4 Posted : Wednesday, March 20, 2013 1:13:42 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Can you send me the sample images that you use? If you want to attach files, make sure to put them in a ZIP or RAR file and don't use the Preview feature.
If the ZIP file is larger than 5MB, you can send your LEADTOOLS SDK serial number (do Not post it here) to support@leadtools.com and ask for FTP upload instructions.

However, the following forum post contains useful information about loading images with alpha channel:
http://support.leadtools.com/CS/forums/41815/ShowPost.aspx
 
Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Wednesday, March 20, 2013 9:49:48 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


I followed the link provided but it is in c#. I tried the online documentation for RasterPaintProperties but cannot find any related topic.

We are currently using VC++ and Raster Imaging Pro v15 toolkit.

I have also attached the image files we want to display and print.
File Attachment(s):
SampleImages.zip (5kb) downloaded 43 time(s).
 
#6 Posted : Wednesday, March 20, 2013 12:39:40 PM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


HI,
I made some experiments using FeatherAlphaBlendBitmap() and tested the ff. code.

RedirectIO(OpenPicFiles, NULL, NULL, NULL, NULL, (L_VOID *)filename) ;

Ret = FileInfo(filename, &fileinfo, sizeof(FILEINFO), 0, NULL);
Ret = InitBitmap(&hLeadBitmap, sizeof(BITMAPHANDLE), fileinfo.Width, fileinfo.Height, fileinfo.BitsPerPixel);
Ret = LoadBitmap(filename, &hLeadBitmap, sizeof(BITMAPHANDLE), hLeadBitmap.BitsPerPixel, hLeadBitmap.Order, NULL, NULL);
// debugging hLeadBitmap.Flags.Transparency, always returns 0

RedirectIO(NULL, NULL, NULL, NULL, NULL, NULL) ;

if( Ret == SUCCESS && fileinfo.Flags & FILEINFO_HAS_ALPHA ){ // check to make sure that it has alpha channels
    Ret = GetBitmapAlpha(&hLeadBitmap, &hLeadAlpha, sizeof(BITMAPHANDLE));
    memset( &hLeadBmpPlusAlpha, 0, sizeof( hLeadBmpPlusAlpha ) ) ;
    hLeadBmpPlusAlpha.uStructSize = sizeof( hLeadBmpPlusAlpha ) ;
    Ret = FeatherAlphaBlendBitmap(&hLeadBmpPlusAlpha, 0, 0, hLeadAlpha.Width, hLeadAlpha.Height,&hLeadBitmap, 0, 0, &hLeadAlpha, 0, 0);
} // if


w_DispModeType = GetDisplayMode() ;
SetDisplayMode(DISPLAYMODE_FIXEDPALETTE|DISPLAYMODE_RESAMPLE|DISPLAYMODE_BICUBIC, DISPLAYMODE_FIXEDPALETTE|DISPLAYMODE_BICUBIC);
hpalPaint = CreatePaintPalette(dc.GetSafeHdc(), &hLeadBitmap);
if (hpalPaint)
{
SelectPalette (dc.GetSafeHdc(), hpalPaint, FALSE);
RealizePalette (dc.GetSafeHdc());
}
PaintDCEffect(dc.GetSafeHdc(), &hLeadBitmapNULL, NULL, &DrawRect, PaintRect, SRCCOPY, 0);
SetDisplayMode(DISPLAYMODE_FIXEDPALETTE|DISPLAYMODE_BICUBIC|w_DispModeType, w_DispModeType) ;

The above code however returns ERROR_NO_BITMAP at FeatherAlphaBlendBitmap(). Also, the sample program on your online documentation (http://www.leadtools.com/help/leadtools/v15/main/api/dllsteps/tuttransparency.htm) has no parameter for nXMaskShift and nYMaskShift os I passed 0.
 
#7 Posted : Thursday, March 21, 2013 4:19:41 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

I modified our API v15 LoadSave demo to display images with alpha channels using the L_FeatherAlphaBlendBitmap function. Note that you need to add the attached project to the following folder:
[LEADTOOLS 15 folder]\Examples\API

After this, please check the following code in the attached demo:
+------------+
case IDM_ALPHA:
if(Data.BitmapHandle.Flags.Allocated && (Data.BitmapHandle.BitsPerPixel == 32))
{
BITMAPHANDLE ForegroundBmp = {0}, AlphaBitmap = {0};
nRet = L_CopyBitmap(&ForegroundBmp, &Data.BitmapHandle, sizeof(BITMAPHANDLE));
nRet = L_FillBitmap(&Data.BitmapHandle,RGB(20, 130, 255));
nRet = L_GetBitmapAlpha(&ForegroundBmp, &AlphaBitmap, sizeof(BITMAPHANDLE));
nRet = L_FeatherAlphaBlendBitmap(&Data.BitmapHandle, 0, 0,AlphaBitmap.Width, AlphaBitmap.Height, &ForegroundBmp, 0, 0, &AlphaBitmap,0,0);
L_FreeBitmap(&ForegroundBmp);
L_FreeBitmap(&AlphaBitmap);
::InvalidateRect(hWnd, NULL, TRUE);
}
break;
+------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
File Attachment(s):
LoadSave.zip (10kb) downloaded 41 time(s).
 
#8 Posted : Thursday, March 21, 2013 8:38:31 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


Based on your latest sample code, I was able to have a successful call of FeatherAlphaBlendBitmap(). The resulting image however is still the same, black on the surroundings.

Is the destination bitmap need to be 24 bit and not 32? According to http://support.leadtools...ums/41815/ShowPost.aspx, "By default, our paint functions do not take the alpha channel into consideration."

How do we create a 24 bit bitmap from 32 bit? Or is there a way to create a 24 bitmap specifying the height, width and bits per pixel and initializing all pixel values to RGB(255,255,255)? A sample with be of great help.
 
#9 Posted : Saturday, March 23, 2013 11:05:52 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

It seems that you didn't run the alpha channel code in the demo. After loading the image using the modified LoadSave demo, you need to click the "Alpha test..." menu to apply the FeatherAlphaBlend function and display the images with alpha cannel.
I am attaching a screenshot that shows how the images appear on my side after applying the L_FeatherAlphaBlendBitmap function.

If you are getting different results, please send your LEADTOOLS Raster Imaging Pro v15 serial number (do Not post it here) to support@leadtools.com and ask about the instructions to download and install the latest LEADTOOLS v15 patches.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
Maen Hasan attached the following image(s):
screenshots.png
 
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.146 seconds.