Problem creating png with alpha channel.

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: helmut, XnTriq, xnview

Post Reply
bertrand
Posts: 2
Joined: Sat Nov 17, 2007 3:12 pm
Contact:

Problem creating png with alpha channel.

Post by bertrand »

I want to use GFLSDK (v2.70) for create png file with alpha channel from DIB on window.
Here is my code:

Code: Select all

------------------------------
                    GFLC_SAVE_PARAMS save_option;
	GFL_ERROR gflError;
	save_option.setFormat(gflGetFormatIndexByName("png"));
	GFLC_BITMAP * bitmap = new GFLC_BITMAP();
	gflError = bitmap->create(GFL_RGBA,128,128);   
//This GFLC_BITMAP is OK with type: GFL_RGBA
	HDIB hdib3d=BitmapToDIB(ghBitmap3d,NULL);
//This DIB is also with 32 bits by pixel
	if (hdib3d) {
		gflError = bitmap->setHBITMAP(hdib3d);  
// Then, the GFLC_BITMAP became a GFL_BGR type (3 components by pixel)!
		bitmap->setTransparentIndex(0);  
 -----------------------
My png file is in RGB, without alpha channel and then no transparency.

I am new on this library, something must be wrong, but what?
Thanks for any answer.
aditional code:

Code: Select all

GFL_ERROR GFLC_BITMAP::setHBITMAP(HDIB hDIB)
{
	ERROR_Check(m_gflBitmap, ""); 
	return  gflConvertDIBIntoBitmap     (hDIB, &m_gflBitmap ); 
} 
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Problem creating png with alpha channel.

Post by xnview »

Which function do you use for BitmapToDIB?
Pierre.
bertrand
Posts: 2
Joined: Sat Nov 17, 2007 3:12 pm
Contact:

Re: Problem creating png with alpha channel.

Post by bertrand »

xnview wrote:Which function do you use for BitmapToDIB?
I use GetDIBits, but it seems to be OK, the DIB was 32 bits/pixels, and I also trie directly "gflConvertDDBIntoBitmap" with the HBITMAP ghBitmap3d, without success.
Bertrand
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Problem creating png with alpha channel.

Post by xnview »

bertrand wrote:
xnview wrote:Which function do you use for BitmapToDIB?
I use GetDIBits, but it seems to be OK, the DIB was 32 bits/pixels, and I also trie directly "gflConvertDDBIntoBitmap" with the HBITMAP ghBitmap3d, without success.
Bertrand
Could you send me your email by PM, i'll send you a fixed version
Pierre.
Post Reply