Hi,
My purpose is to load Image one time at OnInitDialog and set several transparent pixel color on that Image. In my current code, pixel color are filled over Image and I totally can't see the based Image. Here is my code.
BOOL CTestColorDlg::OnInitDialog()
{
CString szFileName(_T("C:\\Users\\User\\Desktop\\ImageData.bmp"));
hBmp = (HBITMAP)::LoadImage(NULL, szFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_bitmap.SetBitmap(hBmp);
return TRUE;
}
void CTestColorDlg::OnPaint()
{
CDialogEx::OnPaint();
ShowPixelData();
}
void CTestColorDlg::ShowPixelData()
{
BITMAP bmpInfo;
GetObject(hBmp, sizeof(BITMAP), &bmpInfo);
CDC* pdc = GetDC();
CDC memDC;
if (memDC.CreateCompatibleDC(pdc))
{
HBITMAP old_hBitmap = (HBITMAP)memDC.SelectObject(hBmp);
memDC.SetBkColor(TRANSPARENT);
for (int i = 0; i < bmpInfo.bmHeight; i++) {
for(int j = 0; j < bmpInfo.bmWidth; j++) {
memDC.SetPixel(j, i, RGB(200, 100, 0));
}
}
memDC.SelectObject((HBITMAP)old_hBitmap);
memDC.DeleteDC();
}
ReleaseDC(pdc);
}
I want to see the Image and fill transparent color on it. With the upper code, I just can see opaque color fill on the Image. Could anyone give me advice for showing transparent color based on upper code? (I don't want to use alphablend.)
And what is the best way to clear setpixel color, when I would like to set completely different setpixel color ? Should I redraw Image and set different color again ??
Thanks in advanced.