View Full Version : Getting pixel position

February 23, 2004, 17:54:45
Hi, I`m new using IC control ActiveX, I want to know how to get the pixel position, I mean I want to put the mouse cursor on the live captured image and get the current position in y and x axis. Is there any funtion for doing this?. Thanks in advance.

Stefan Geissler
February 24, 2004, 15:33:12

The current mouse position on the live video window of IC Imaging Control.OCX is specified as parameter in the MouseMove, MouseDown and MouseUp event sub of IC Imaging Control.

Private Sub ICImagingControl1_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal XPos As Integer, ByVal YPos As Integer)
End Sub

February 26, 2004, 17:27:28
Thanks for your help. Can you know help me about OverlayBitmap? My question is this, I'm working with the overlay feature, with the information about pixel position, i'm drawing a rectangle every time I click the mouse button, by now I want to refresh the image for erasing older rectangles and having just the current one, How can I acomplish that thing? Thanks for your help!

Stefan Geissler
February 27, 2004, 12:01:47

This is very simple. Before drawing the rectangle with the new mouse position, draw it using the current DropOutColor with the old positions. See property DropOutColor of OverlayBitmap.

You should also save the coordinates of the previous painted rectangle.

March 3, 2004, 19:28:01
OK Thank you very much, I get the idea, I've done it but when I'm trying to draw a transparent rectangle the dropoutcolor is only a kind of green, I'm using Delphi 7 but for mostly proyects ideas are the same as in VB, I attach some code:

procedure DrawRect(color:integer;x1:integer;y1:integer;x2:in teger;y2:integer);
Form1.IC1.OverlayBitmap.DrawLine(color,x1,y1,x2,y1 );
Form1.IC1.OverlayBitmap.DrawLine(color,x1,y1,x1,y2 );
Form1.IC1.OverlayBitmap.DrawLine(color,x2,y1,x2,y2 );
Form1.IC1.OverlayBitmap.DrawLine(color,x1,y2,x2,y2 );

procedure TForm1.IC1MouseDown(ASender: TObject; Button, Shift: Integer;
XPos, YPos: Smallint);

OldYPos and OldXPos are global variables. I guess I'm using dropout color property in the wrong way. Thanks for your help:)

Stefan Geissler
March 4, 2004, 07:33:27

You did all right, in a Visual Basic program this would work fine. I am not familiar with Delphi's data types, but the DropOutColor is of type long (4 bytes length, unsigned). The DropOutColor is set to 0 by default. Therefore you could specify 0 instead of “IC1.OverlayBitmap.DropOutColor” when you delete the rectangle at the old position.

March 4, 2004, 15:59:36
Hey, it works really fine thank you very much for your great help, I just change dropoutcolor property to 0 and that's all...