danginkgo wrote:
When I display the image using AlphaBlend() function the image looks the same as when I displayed it using BitBlt().
Then all the alpha channel values must be 255.
danginkgo wrote:
Is it posible using this function?
Yes. Try something like this, creating and rendering your own 32bpp ARGB bitmap:
LONG lImageWidth = 640;
LONG lImageHeight = 480;
WORD wBitsPerPixel = 32;
LONG lStride = lImageWidth * 4;
BYTE* pBitmapBits;
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = lImageWidth;
bmi.bmiHeader.biHeight = lImageHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = wBitsPerPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = lStride * lImageHeight;
//bmi.bmiHeader.biXPelsPerMeter = 0;
//bmi.bmiHeader.biYPelsPerMeter = 0;
//bmi.bmiHeader.biClrUsed = 0;
//bmi.bmiHeader.biClrImportant = 0;
HDC hdcMem = ::CreateCompatibleDC(0);
HBITMAP hBitmap = ::CreateDIBSection(hdcMem, &bmi, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);
if (hBitmap)
{
memset(pBitmapBits, 0, bmi.bmiHeader.biSizeImage);
RGBQUAD *pCurPixel = (RGBQUAD *)pBitmapBits;
int PixelCount = lImageWidth * lImageHeight;
while (PixelCount > 0)
{
(*pCurPixel).rgbRed = 0x00;
(*pCurPixel).rgbGreen = 0x00;
(*pCurPixel).rgbBlue = 0xA0;
(*pCurPixel).rgbReserved = 0x80;
pCurPixel++;
PixelCount--;
}
HGDIOBJ hOldBitmap = ::SelectObject(hdcMem, hBitmap);
HDC hClientDC = ::GetDC(\*this);
HPEN hPen = ::CreatePen(PS\_SOLID, 10, RGB(255,0,128));
HGDIOBJ hOldPen = ::SelectObject(hClientDC, hPen);
::MoveToEx(hClientDC, 0, 0, NULL);
::LineTo(hClientDC, 650, 490);
::SelectObject(hClientDC, hOldPen);
::DeleteObject(hPen);
BLENDFUNCTION bf;
bf.BlendOp = AC\_SRC\_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 0xFF;
bf.AlphaFormat = AC\_SRC\_ALPHA;
::AlphaBlend(hClientDC, 0, 0, lImageWidth, lImageHeight,
hdcMem, 0, 0, lImageWidth, lImageHeight, bf);
::ReleaseDC(\*this, hClientDC);
::SelectObject(hdcMem, hOldBitmap);
::DeleteObject(hBitmap);
}
::DeleteDC(hdcMem);