简体   繁体   中英

using painteventargs in a c# form; how do I draw a larger image to the Graphics object (with scrollbars as well)?

I'm writing some data acquisition code. As the app acquires data it draws a graph to a content pane. Everything works perfectly right now for our data comprised of fixed length scans: the graph is just scaled to fit into the graphics object obtained from painteventargs. We are now implementing a "free scan" that just grows in length as you collect data. We would like to draw the graph, which is ever increasing in size, to the graphics object from painteventargs but once it grows larger than the graphics object an "out of memory" exception is generated. Is there a way to grow the graphics object or simply replace it? We want to be able to use the scroll bars to see all of the data.

Thanks for any help!

Here's a chunk of the code (Note: I understand why I'm getting the out of memory error -- the bitmap is too big. This was just one attempt to do what I'm trying to do. I'm asking the question because I'm stumped at the moment.):

    System.Drawing.Graphics G = e.Graphics;
    e.Graphics.Clear(System.Drawing.Color.White);                
    Bitmap bm = new Bitmap(10000, 1000);
    Graphics h = Graphics.FromImage(bm);
    h.DrawLine(myPens[0], 0, 0, 1000, 10000);
    G.DrawImage(bm,0,0);

What I'd recommend you is calculating average points and graph them instead of every single data point. This is also done by leading chart controls. To not to hide details from the user, you should implement a zooming function which takes only a specific interval of your data. As more as you zoom in the less the interval of time. And the more you Zoom in the more details you can show. Hope this strategy will help you further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM