PNG picture transparent background is always a white, only later found that this is actually Microsoft GDI + design problem, png picture is ARGB, use GDI + load the picture, GDI + will default has been the pre-residual operation (PARGB), That is, the actual value of each pixel is already proportional to the alpha value of the result, in fact it does not do a prefetch, in the use of transparent image of the Pixel alpha channel, CImage inside is the call of the AlphaBlend, The result of a picture that does not have a pre-multiplication as a pre-multiply image is that this is the equivalent of a single and white background, so the image always appears as a white background.
The final solution, write a small program to the PNG image of each pixel for the operation, and then save the PNG picture, the actual effect is good.
I overwrote cimage::load () and now everything works fine:
HRESULT cimg::load (LPCTSTR pszfilename, bool bpremultiply)
{
hresult retres = Cimage::load ( pszFileName);
if (! IsNull () && bpremultiply)
{
unsigned char * pcol = 0;
long LW = getwidth ();
long LH = GetHeight ();
for (Long ixy = 0; Ixy < LH; Ixy + +)
{
for (Long Ixx = 0; Ixx < LW ; Ixx + +)
{
pcol = (unsigned char *) getpixeladdress (IXX,IXY);
unsigned char alpha = pcol[3];
if (Alpha < 255)
{
pcol[0] = ( (pcol[0] * Alpha) + 127)/255;
pcol[1] = ((pcol[1] * Alpha) + 127)/255;
pcol[2] = ((pcol[2] * Alpha) + 127)/255;
}
}
}
}
return retres;
}
PS: Finally found that there are some PNG map of the transparent color can be processed properly, and now suspect that these pictures are not exported the way the resulting.