Reputation: 2251
I am creating a user interface and actualy drawing bitmap this way:
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP oldBmp = (HBITMAP)SelectObject(hdcMem, mouseover? bitmapover:bitmap);
StretchBlt(hdc, xabs, yabs, width, height, hdcMem, 0, 0, worg, horg, SRCCOPY);
SelectObject(hdcMem, oldBmp);
DeleteDC(hdcMem);
But I can only draw flat images and I need to draw transparent ones (several alpha levels). I tried things with GetDIBits
and SetDIBits
but I failed drawing anything. I can use png or modify the bitmap pixel by pixel which is simpler, I just want to avoid using libraries with dlls or restrictive licences.
Upvotes: 1
Views: 1335
Reputation: 37468
To draw semi-transparent bitmatps you can utilize GdiAlphaBlend
function. Note that bitmap with alpha channel that you are going to draw using this API need to have premultiplied alpha.
Upvotes: 1