Detecting a pixel on the SDI
-
Hi all, 1) If I drawn a line on SDI client by using MoveTo() and LineTo(). Is there any method to detect which pixel is drawn? I need to get the coordinates of these pixels. 2) Is there any function in MFC that can calculate the distance of a drawn line (or bezier curve) from the starting point to the endpoint? 3) There is a guide in codeproject.com to redraw the drawn lines when the client window is resized/maximized/minimized. I tried and it works however, there are some codes I wrote in OnDraw to draw out the coords/axis of the client. These drawing from OnDraw is covering my META redrawn line. Please advise. THanks a million. ;)
-
Hi all, 1) If I drawn a line on SDI client by using MoveTo() and LineTo(). Is there any method to detect which pixel is drawn? I need to get the coordinates of these pixels. 2) Is there any function in MFC that can calculate the distance of a drawn line (or bezier curve) from the starting point to the endpoint? 3) There is a guide in codeproject.com to redraw the drawn lines when the client window is resized/maximized/minimized. I tried and it works however, there are some codes I wrote in OnDraw to draw out the coords/axis of the client. These drawing from OnDraw is covering my META redrawn line. Please advise. THanks a million. ;)
- There's the CDC::GetPixel(), which can give you the color of a pixel knowing its coordinates, But I'm not sure it's what you want. You can still use the good old geometric equations, knowing two points you know the equation of the line, so the coordinates of all the points of the line. 2) Not at my knowledge. The length of a segment is given by the formula length = sqr((endpoint.x - startpoint.x)*(endpoint.x - startpoint.x) + (endpoint.y - startpoint.y)*(endpoint.y - startpoint.y)). Calculating the length of a bezier curve is a little trickier, you may find a good approximation here[^]. 3) Make all your drawings in your OnDraw method, and begin to draw items who are "behind" at first.
Fold With Us! War is too serious a matter to entrust to military men - Georges Clémenceau (1841-1929)
-
- There's the CDC::GetPixel(), which can give you the color of a pixel knowing its coordinates, But I'm not sure it's what you want. You can still use the good old geometric equations, knowing two points you know the equation of the line, so the coordinates of all the points of the line. 2) Not at my knowledge. The length of a segment is given by the formula length = sqr((endpoint.x - startpoint.x)*(endpoint.x - startpoint.x) + (endpoint.y - startpoint.y)*(endpoint.y - startpoint.y)). Calculating the length of a bezier curve is a little trickier, you may find a good approximation here[^]. 3) Make all your drawings in your OnDraw method, and begin to draw items who are "behind" at first.
Fold With Us! War is too serious a matter to entrust to military men - Georges Clémenceau (1841-1929)
Thanks K(arl), The program I need to write: 1st) User is required to draw a simple curve on the client. 2nd) The algorithm will scan the SDI client screen to find all the drawn coords on row/col basis. You have suggested to use CDC::GetPixel(). 3rd) Once a drawn pixel is found it will perform a 3x3 matrix check to determine the "connectivity" of this pixel. http://img52.exs.cx/img52/2303/3x3matrix.gif[^]If there are other drawn pixels in this 3x3 matrix, the drawn pixel is not an island. 4th) The program will keep scanning in loop to get to the end point of the curve. From there, the program will mark down a point for each specific distance of pixels. http://img40.exs.cx/img40/513/curve.gif[^] That is why I asked is there any function to check distance between endpoint to endpoint of a curve. My problem: 1) Is there a better way than my algorithm? Anyone has a better idea to scan pls reply here. My method is very tedious. THanks. 2) If there is an intersection such as the two curves intersection point. The program will be bugged (I foresee). Thanks a million