I have to present images on a picture control that are a composition of two PNG files, where the top image has transparent pixels on certain positions.
The result shoul
After some days and night of desperation, I've finally found http://forums.codeguru.com/showthread.php?420631-setting-CImage-alpha-values&p=1560260#post1560260 which a solution similar to what I've tried, but with the addition of 127 to every pixel, which is a thing that worked but I've not understood at the time, nor I had made any effort to understand it yet. So before the AlphaBlend
line now there is:
for (int i = 0; i < imageBar.GetWidth(); i++)
{
for (int j = 0; j < imageBar.GetHeight(); j++)
{
BYTE* ptr = (BYTE*)imageBar.GetPixelAddress(i, j);
ptr[0] = ((ptr[0] * ptr[3]) + 127) / 255;
ptr[1] = ((ptr[1] * ptr[3]) + 127) / 255;
ptr[2] = ((ptr[2] * ptr[3]) + 127) / 255;
}
}
and now the displayed image is well composed.