Hello,
I have an Image Box that has a grid on it which displays an icon. When a user clicks the left mouse button and drags it over the picture box it fills in the pixel with the select color.
The problem is this, when a user moves the mouse to fast it misses pixels. If the mouse is moved moderatly fast it will miss about every third, if it is fast then it will miss around 4 then draw one.
So it looks like this:
- - -- - --
Where the - are representing filled in spaces when a user drags fast in a straight line.
The method I use is dc.FillSolidRect(...). When the mouse is dragged slow, this problem doesn't occur. I think that the OnMouseMove commands are not completing (or that is the way it seems).
Any ideas on how to make this work? I've created a DoEvents class and added that which didn't help.
Here is the code:
if (m_bDragging == true) {
mDC->FillSolidRect(lastCol * space + 1, lastRow * hSpace,space - 1, hSpace - 1, ForeColor);
}
lastCol represents the previous x (I.E. 4)
lostRow is previous y (I.E. 3)
Space and hspace are the width of the block (for zooming, can be anywhere from 5-30 in size)
I've tried setting the current row and pixel to the color with the same effect.
Any help?
Use a projected line to draw the pixels.
If user starts a E3 and ends at G3 draw a line. Using this method you can also draw as the user moves real fast.
Void
So, what you are saying Void, is that I should create an algorithm to draw the line so that when the user moves fast I will not miss pixels?
Yes, have an algorithm to draw a straight line from point A to point B. Draw an eclipse or circle otherwise. I once created a graphics program that had this same problem and that is how I resolved it. I no longer have the code or I would post it here. Let me know if you have any more problems with it though.
Void
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks