Hi,
I would like to draw transparent color on bitmap. But, when I write the code as follow and run it, the bitmap is covered on color. What is wrong on my code? Also, is there any unnecessary code in my program ?
The process is as follow:
I import bitmap resource to MFC CDialog program. Add picture control to CDialog and add the previous imported bitmap to picture control. Set picture control property as transparent.
Then, I add the follow code to onpaint.
CDC dc;
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP_TESTBITMAP);
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
CDC* pDC = this->GetDC();
dc.CreateCompatibleDC(pDC);
CBitmap* pOldBmp = dc.SelectObject(&bmp);
for (int i = 0; i < bmpInfo.bmHeight; i++) {
for(int j = 0; j < bmpInfo.bmWidth; j++) {
dc.SetPixel(j, i, RGB(rand()%100, rand()%50, rand()%100));
}
}
pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dc, 0, 0, SRCAND);
dc.SelectObject(pOldBmp);
bmp.DeleteObject();
dc.DeleteDC();
this->ReleaseDC(pDC);
CDialogEx::OnPaint();
Thanks for your help and time.