
vecchio56
|
Ah, j'ai trouvé une solution d'avoir lu la tienne (une source en MFC
que j'ai traduit), je ne sais pas laquelle est la meilleure. En fait je
voulais avoir une couleur de transparence (ici RGB(0, 255, 0)).
J'obtiens mon résultat dans m_hdcImage. Seul problème: je ne vois pas
d'ou vient le 0x220326.
HDC hdcImage = CreateCompatibleDC(hdc);
HBITMAP hbmpImage = LoadBitmap(g_hInst, (LPCTSTR)m_nBitmap);
SelectObject(hdcImage, hbmpImage);
HDC hdcAnd = CreateCompatibleDC(hdc);
HBITMAP hbmpAnd = CreateBitmap(16, 15, 1, 1, 0);
SelectObject(hdcAnd, hbmpAnd);
SetBkColor(hdcImage, RGB(0, 255, 0));
BitBlt(hdcAnd, 0, 0, 16, 15, hdcImage, 0, 0, SRCCOPY);
HDC hdcXor = CreateCompatibleDC(hdc);
HBITMAP hbmpXor = CreateCompatibleBitmap(hdcImage, 16, 15);
SelectObject(hdcXor, hbmpXor);
BitBlt(hdcXor, 0, 0, 16, 15, hdcImage, 0, 0, SRCCOPY);
BitBlt(hdcXor, 0, 0, 16, 15, hdcAnd, 0, 0, 0x220326);
m_hdcImage = CreateCompatibleDC(hdc);
m_hbmpImage = CreateCompatibleBitmap(hdcImage, 16, 15);
SelectObject(m_hdcImage, m_hbmpImage);
BitBlt(m_hdcImage, 0, 0, 16, 15, hdc, 0, 0, SRCCOPY);
BitBlt(m_hdcImage, 0, 0, 16, 15, hdcAnd, 0, 0, SRCAND);
BitBlt(m_hdcImage, 0, 0, 16, 15, hdcXor, 0, 0, SRCINVERT);
DeleteObject(hbmpImage);
DeleteObject(hdcImage);
DeleteObject(hbmpAnd);
DeleteObject(hdcAnd);
DeleteObject(hbmpXor);
DeleteObject(hdcXor);
|