On Tue, Oct 28, 2014 at 10:58:14AM -0500, Vincent Povirk wrote:
- return ((b + ((BYTE)bkgnd * (255 - alpha) + 127) / 255) |
What's the purpose of adding 127 here?
It compensates for C's truncation on integer division. We have exactly the same code in the dib engine, so I borrowed it from there.
stat = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead|ImageLockModeUserInputBuf, PixelFormat32bppPARGB, &lockeddata);
if (background & 0xffffff)
{
DWORD *ptr;
UINT i;
for (ptr = (DWORD*)bits, i = 0; i < width * height; ptr++, i++)
{
if ((*ptr & 0xff000000) == 0xff000000) continue;
*ptr = blend_argb_no_bkgnd_alpha(*ptr, background);
}
}
I guess it wouldn't hurt anything, but it doesn't make much sense to do this if LockBits fails.
Yes, I should test that and probably move this after the Unlock.
Thanks, Huw.