PixelData example for Visual Basic
' This example, using the MouseDown event, gets the value of the current pixel and sets all values in the line to that value. The example shows how to convert mouse coordinates to bitmap pixel coordinates, regardless of how the image is zoomed or scrolled.
Private Sub LEADRasterView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Dim RasterVar As New LEADRasterVariant
Dim xfraction As Single
Dim yfraction As Single
Dim xPixel As Long
Dim yPixel As Long
'In VB, you get TWIPS; so set the scale mode accordingly.
LEADRasterView1.Raster.ScaleMode = SCALEMODE_TWIP
'Translate mouse coordinates to fractions of the destination width and height.
xfraction = (x - LEADRasterView1.DstLeft) / LEADRasterView1.DstWidth
yfraction = (y - LEADRasterView1.DstTop) / LEADRasterView1.DstHeight
'Set the scale mode to pixels and convert fractions to bitmap pixel coordinates.
LEADRasterView1.Raster.ScaleMode = SCALEMODE_PIXEL
xPixel = (LEADRasterView1.SrcWidth * xfraction) + LEADRasterView1.SrcLeft
yPixel = (LEADRasterView1.SrcHeight * yfraction) + LEADRasterView1.SrcTop
'Make the whole line the same color as the pixel.
Set RasterVar = LEADRasterView1.Raster.PixelData(xPixel, yPixel)
'disable repainting
LEADRasterView1.AutoRepaint = False
For xPixel = 0 To LEADRasterView1.Raster.BitmapWidth - 1
LEADRasterView1.Raster.PixelData(xPixel, yPixel) = RasterVar
Next
' re-enable repainting
LEADRasterView1.AutoRepaint = True
LEADRasterView1.ForceRepaint
End Sub