I'm trying to take an existing image on a DC and adjust its colors
If i understand conceptually, i'm supposed to:
1) make a new memory device context
2) create a bitmap for the new DC
3) SelectObject that new bitmap into the new DC
4) BitBlt the contents of the original DC to the new memory DC
5) DrawImage with a matrix to adjust the colors on the new bitmap
6) BitBlt the image back to the original DC
Code: Select all
hDC := GetDC(hGui)
hDC_Memory := CreateCompatibleDC(hDC)
G_Memory := Gdip_GraphicsFromHDC(hDC_Memory)
pBitmap_Memory := CreateCompatibleBitmap(hDC_Memory, w, h)
hBitmap_Memory := Gdip_CreateHBITMAPFromBitmap(pBitmap_Memory, 0x00FFFFFF)
SelectObject(hDC_Memory, hBitmap_Memory)
BitBlt(hDC_Memory, 0, 0, w, h, hDC, 0, 0)
Matrix = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1 ;grayscale
Gdip_DrawImage(G_Memory, pBitmap_Memory, 0, 0, W, H, 0, 0, W, H, Matrix)
BitBlt(hDC, 0, 0, w, h, hDC_Memory, 0, 0)
thanks