Pixel example for Visual Basic

Note: Also works with Access 95 and 97.

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 xycolor As Long
   Dim xfraction As Single
   Dim yfraction As Single
   Dim xPixel As Long
   Dim yPixel As Long
   'Translate mouse coordinates to fractions of the destination width and height.
   LEADRasterView1.BackErase = False
   xfraction = (x - LEADRasterView1.DstLeft) / LEADRasterView1.DstWidth
   yfraction = (y - LEADRasterView1.DstTop) / LEADRasterView1.DstHeight
   'convert fractions to bitmap pixel coordinates.
   xPixel = (LEADRasterView1.SrcWidth * xfraction) + LEADRasterView1.SrcLeft
   yPixel = (LEADRasterView1.SrcHeight * yfraction) + LEADRasterView1.SrcTop
   'Make the whole line the same color as the pixel.
   xycolor = LEADRasterView1.Raster.Pixel(xPixel, yPixel)
   For xPixel = 0 To LEADRasterView1.Raster.BitmapWidth - 1
      LEADRasterView1.Raster.Pixel(xPixel, yPixel) = xycolor
   Next
   LEADRasterView1.ForceRepaint
End Sub