|
-
Apr 15th, 2010, 11:27 AM
#1
Re: GDI functions are slowing down Winsock
UW
I'm not familiar with InvalidateRect API, but if I understand you properly,
you only issue this when you need to refresh the PictureBox (ie, if datapoint
is beyond current graph extremes).
If this is correct, do you by any chance know in advance what the min and/or
max values of x and y will be? If so, perhaps as a test, you could simply
omit the "zoom to fit" feature.. just see if you can populate the graph with
all pieces of data. If that works, we can move on to the "next step."
Spoo
-
Apr 15th, 2010, 11:59 AM
#2
Thread Starter
Junior Member
Re: GDI functions are slowing down Winsock
I need to refresh the graph always, even if the data point is with in the PictureBox. This is needed because the PictureBox will not update on its own with GDI functions, you have to tell it to refresh the hardware (screen). InvalidateRect simply tells the OS "When you get the time, write/update the screen for the user." As oppose to PictureBox.Refresh which forces Windows to update immediately; this is what was explained to me. I will not know the values ahead of time. This software communicates with equipment in the lab and plots the data returned from the experiment. I've implemented the:
If( GetTickCount - lLastCount > TimeOut OR nPoints > MaxPoints) Then SendData
See previous post. I'll let you guys know how well it worked, or failed, once I test it.
-
Apr 15th, 2010, 12:10 PM
#3
Re: GDI functions are slowing down Winsock
 Originally Posted by UWGRAD
I need to refresh the graph always, even if the data point is with in the PictureBox. This is needed because the PictureBox will not update on its own with GDI functions, you have to tell it to refresh the hardware (screen).
Not necessarily true all the time. If the .AutoRedraw=False, it should update pretty much immediately (message queue size dependent), no need to invalidate. I might have it backwards regarding the AutoRedraw value, but you can quickly test this in a temp project.
Per MSDN documentation for WM_PAINT: The system sends this message when there are no other messages in the application's message queue.
The queue doesn't stay full very long unless the system/another window is flooding it.
Anyway, you said you have to Invalidate even if point is in the picturebox. But when you do this, is your invalidation rectangle only the size/position of that point? If not, do so and you should see some improvement. This is where I was attempting to go in post #3 above.
-
Apr 15th, 2010, 12:31 PM
#4
Thread Starter
Junior Member
Re: GDI functions are slowing down Winsock
AutoRedraw = True for my PictureBox. I was going to implement the RECT area just to the bounds of the LineTo command so only a small portion got updated. But when the graph needs to be rescaled I have to update the whole RECT of the PictureBox. At least 50% of the time this may be the case:
Pseudo:
FillRect
MoveTo X0, Y0
LineTo X1, Y1
LineTo X2, Y2,
...
LineTo Xn, Yn
InvalidateRect
I plan on using your suggestion, but 50% of the time it will still maintain the slow speed.
-
Apr 15th, 2010, 12:41 PM
#5
Re: GDI functions are slowing down Winsock
 Originally Posted by UWGRAD
I plan on using your suggestion, but 50% of the time it will still maintain the slow speed.
Yes but 50% of the time it will be lightening fast. Take a simple point for example, say 2x2 pixels and a screen size of just 256x256. Updating just that point updates only 4 pixels vs 65,536 pixels for the entire window, for each new point drawn within the graph. I know that is oversimplification, but the savings are real.
Edited: Other optimizations, maybe, can be put into play. But that would require you to post your drawing routines and if you decide to do that, you might want to post that in the graphics section of the forum with a new topic title, like "Drawing Optimization Tips", for example.
Last edited by LaVolpe; Apr 15th, 2010 at 12:45 PM.
-
Apr 15th, 2010, 12:49 PM
#6
Thread Starter
Junior Member
Re: GDI functions are slowing down Winsock
I like your suggestion, I will put it in once I get the chance and test it out. I'll let you know how it works.
Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|