Q: How can I retrieve or specify the color of specified pixel?
A: You can use the GetDIBPixelColor method from BiDIB.ocx to determine the color of the pixel. This method supports monochrome, 8 and 24 bit per pixels DIBs. You must specify the device independent bitmap, the coordinates of the pixel, and then the method retrieves the color of the specified pixel in the third parameter. You can obtain the DIB by loading from files, databases etc.
You can specify the color of the pixel by using the SetDIBPixelColor method. This method is available in BiDIB.ocx. The SetDIBPixelColor works for only monochrome, 8, and 24 bit per pixel device independent bitmaps. You must specify the DIB, the coordinates of the pixel and the new color of the pixel.
Code example:
Private Sub MyMethod(ByVal FileName As String, ByVal x As Long, ByVal y As Long)
Dim Dib As Long
Dim color(3) as Long
…
Dib = BiDib.LoadDibFromFile(FileName)
If Dib > 0 Then
If BiDib.GetDIBPixelColor(Dib, x, y, color(0)) Then
…
End If
…
If BiDib.SetDIBPixelColor(Dib, x, y, color(0)) Then
…
End If
End If
…
End Sub