I have a control in which a TIFF file is displayed with dithering, ie not just black and white but shades of grey.
I want to copy the control screen data into a memory device context and work with the pixels there.
The code I have seems to copy only black(0) and white(HFFFFFF)
into the memory DC. When I run the code I get no stops on colors between black and white but when I use getpixel on the control I get shades of grey as well.
I am sure that I am doing something dumb with the API but I don't know what.
dim chdc as long, cbmp as long, x as long, y as long
Const SRCCOPY = &HCC0020
cHdc = CreateCompatibleDC(ctl.hdc)
cBmp = CreateCompatibleBitmap(cHdc, _
ctl.width, ctl.height)
rc = SelectObject(cHdc, cBmp)
rc = BitBlt(cHdc, 0, 0, ctl.width, ctl.height, _
ImgX.hdc, 0, 0, SRCCOPY)
For x = 0 To ctl.width
For y = 0 To ctl.height / 4
c = GetPixel(cHdc, x, y)
If (c = -1) Then
c = c ' never stops
End If
If (c <> &HFFFFFF) And (c <> 0) Then
c = c ' never stops
End If
Next
Next
End If
Next
DeleteDC (cHdc)
DeleteObject (cBmp)
I want to copy the control screen data into a memory device context and work with the pixels there.
The code I have seems to copy only black(0) and white(HFFFFFF)
into the memory DC. When I run the code I get no stops on colors between black and white but when I use getpixel on the control I get shades of grey as well.
I am sure that I am doing something dumb with the API but I don't know what.
dim chdc as long, cbmp as long, x as long, y as long
Const SRCCOPY = &HCC0020
cHdc = CreateCompatibleDC(ctl.hdc)
cBmp = CreateCompatibleBitmap(cHdc, _
ctl.width, ctl.height)
rc = SelectObject(cHdc, cBmp)
rc = BitBlt(cHdc, 0, 0, ctl.width, ctl.height, _
ImgX.hdc, 0, 0, SRCCOPY)
For x = 0 To ctl.width
For y = 0 To ctl.height / 4
c = GetPixel(cHdc, x, y)
If (c = -1) Then
c = c ' never stops
End If
If (c <> &HFFFFFF) And (c <> 0) Then
c = c ' never stops
End If
Next
Next
End If
Next
DeleteDC (cHdc)
DeleteObject (cBmp)