Available in the LEADTOOLS Imaging toolkit. |
Pixel example for Access 2.0
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.
Sub Lead1_MouseDown (Button As Integer, Shift As Integer, x As Long, y As Long)
Dim xycolor As Long
Dim xfraction As Single
Dim yfraction As Single
Dim xPixel As Long
Dim yPixel As Long
''In Access, you get TWIPS; so set the scalemode accordingly.
Me![LEAD1].Object.ScaleMode = 1
Me![LEAD1].Object.AutoRepaint = False
'Translate mouse coordinates to fractions of the destination width and height.
xfraction = (x - Me![LEAD1].Object.DstLeft) / Me![LEAD1].Object.DstWidth
yfraction = (y - Me![LEAD1].Object.DstTop) / Me![LEAD1].Object.DstHeight
'Set the scalemode to pixels and convert fractions to bitmap pixel coordinates.
Me![LEAD1].Object.ScaleMode = 3
xPixel = (Me![LEAD1].Object.SrcWidth * xfraction) + Me![LEAD1].Object.SrcLeft
yPixel = (Me![LEAD1].Object.SrcHeight * yfraction) + Me![LEAD1].Object.SrcTop
'Make the whole line the same color as the pixel.
xycolor = Me![LEAD1].Object.Pixel(xPixel, yPixel)
For xPixel = 0 To Me![LEAD1].Object.BitmapWidth
Me![LEAD1].Object.Pixel(xPixel, yPixel) = xycolor
Next
Me![LEAD1].Object.ForceRepaint
End Sub