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 : Wednesday, June 5, 2013 10:39:28 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


Hello,

How do we different differentiate a 32 bit PNG/BMP file with transparency and without? I have attached the zip file containing image files. I tried referencing the value of BITMAPHANDLE.Flags.Transparency but the value is zero. Currently we are using LEADTOOLS Raster Imaging Pro version 15.0 toolkit.

Thanks
File Attachment(s):
BackIcon.zip (3kb) downloaded 29 time(s).
 

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, June 5, 2013 11:55:39 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


Even BITMAPHANDLE.Transparency is zero.
 
#3 Posted : Wednesday, June 5, 2013 12:45:35 PM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


I made some further experimentation and noticed the ff.

For 32 bit PNG/BMP file without transparency, the result of L_GetBitmapAlpha(), fills the BITMAPHANDLE.Addr.Windows.pData with 0xff.

Is the ff. code to test for this?
-------
    BOOL w_LTBitmapHandleCached = FALSE ;
    if( hLeadBitmap.BitsPerPixel == 32 && hLeadBitmap.Flags.Allocated && ( fileInfo.Flags & FILEINFO_HAS_ALPHA ) ){
        BITMAPHANDLE hLeadAlpha ;
       (*leadFuncs.pGetBitmapAlpha_fn)(&hLeadBitmap, &hLeadAlpha, sizeof(BITMAPHANDLE));
       ULONG* w_LongPtr ;
       bool w_Loop = true ;
       for( int a = 0; w_Loop && a < hLeadAlpha.Height; a++ ){
           for( int b = 0; w_Loop && b < hLeadAlpha.Width; b++ ){
               w_LongPtr = ( ULONG* )&hLeadAlpha.Addr.Windows.pData[ a + b*4 ] ;
               w_Loop    = *w_LongPtr == 0xffffffff ;
           } // for
       } // for
       (*leadFuncs.pFreeBitmapfn)(&hLeadAlpha);
       if( !w_Loop ){
           *hLTBitmap = new BITMAPHANDLE ;
           memcpy( *hLTBitmap, &hLeadBitmap, sizeof( hLeadBitmap ) ) ;
           w_LTBitmapHandleCached = TRUE ;
       } // if
    } // if

-------
 
#4 Posted : Thursday, June 6, 2013 4:44:54 AM(UTC)

mohamed  
mohamed

Groups: Registered, Tech Support
Posts: 179


If you want to know if the image has a alpha image with transparency by code, the easiest way to do that is as follows:
1. Get the alpha bitmap using L_GetBitmapAlpha() method.
2. Use L_GetBitmapColorCount()  method on the alpha bitmap and check the color count.
3. If the color count is more than one, this means that the image has a transparency.
4. If the color count is only one color, check the first pixel in the alpha bitmap and see if it White or Black.
a) If the first pixel is white, then the image doesn't have transparency.
b) If the first pixel is Black or non white color, then the image has transparency.

Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
#5 Posted : Thursday, June 6, 2013 6:50:33 AM(UTC)
cabral_ea_jp

Groups: Registered
Posts: 12


Thank you for the detailed explanation.
For item 4 when color is 1, to check the first pixel, what is the best and efficient way to do this?
I am thinking of using L_ConvertToDDB() which will return a HBITMAP and scan the pixel of this HBITMAP. Please advice.
 
#6 Posted : Sunday, June 9, 2013 3:26:02 AM(UTC)

mohamed  
mohamed

Groups: Registered, Tech Support
Posts: 179


You can use L_GetPixelColor() method and pass zero for the Row and Column to get the first pixel color of the Alpha Bitmap. See the following online topic:
http://www.leadtools.com/help/leadtools/v18/main/api/dllref/l_getpixelcolor.htm

Note: The link is valid at the time of posting.
Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
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-2019, Yet Another Forum.NET
This page was generated in 0.119 seconds.