On Mon, May 4, 2009 at 9:08 AM, lostgallifreyan <lostgallifre...@gmail.com> wrote: > > I'm drawing a GPS track on a chart (actually, an aerial image). So far so > good, but the image is huge, it's slow to load and doesn't always render in > W98. (More on this in a recent post here, I'm still hoping for some ideas to > help with that because Paint Shop has no trouble with it on the same system). >
Make sure that you're not collecting wxBitmaps, you can keep a dozen of them or so at any one time, but not too many more. I think a rule of thumb is, 50 of wxPens, wxFonts, wxColours, wxBitmaps, wxRegions... etc see my reply for a link to the docs. > > What I want to do is load the image, then load one (or more) track data > files. I want to see the track(s) drawn on top of the chart, but not ON it > exactly, I want to be able to delete tracks, or even parts of tracks, or > highlight selected subsets of tracks... Thus I need layers that are > transparent, ideally done in a way that does not make a ful bitmap-sized form > for each layer printed. If you want to get really fancy you can try to see about the status of wxArt2D. This is a nice vector drawing set of classes for wxWidgets and the author was working on making a wxLua bindings. > A few things I learned: > 1. Anything printed to a window is a single opaque image, any 'transparency' > (perhaps not including alpha stuff specific to WXP or other systems I'm not > using) is a thing arranged prior to rendering a single plane of graphic data. Right, wxWidgets doesn't do too much with transparency. I think the very latest version has introduced transparency for pens and drawing. > 2. A bitmap copied to another variable is still the same bitmap, at least > until one of them is edited, then Copy On Write occurs. This could be very > slow for a huge one... It might not be too bad, it'll just be a raw memcopy. The conversion from wxBitmap <--> wxImage will be slow. > 3. Transparency in drawing tools appears to be equivalent to lifting the pen > or brush. It does not cause an image plane to 'melt' showing me what was > originally underneath. If it had, it might have helped me, but it won't. (I'd > played around with two bitmaps on one panel...) > > Anyway, I found many ways to try, none useful. And I guess there is a CORRECT > way. Looking at Scribble didn't help, as it doesn't do layers anyway. > Actually I couldn't even see how Scribble defines its background as white, > yet, though I'm about to go in and see if it just drew a filled rectangle > with a default colour or something because I can't see any explicit setting > of that white background anywhere... > If I understand correctly, I would 1) Load a wxImage of your image file. 2) Use wxImage::GetSubImage() to crop to the visible portion and convert it to a sub wxBitmap that you reuse and is always updated to contain the current background image, immediately delete the sub wxImage. 3) Collect your lines and objects to draw in a list along with anything else they'd need, color, widths, status, etc. Then... In your scrollbar handler you repeat the wxImage -> GetSubImage -> wxBitmap and call wxWindow::Refresh(false) if necessary. In your wxWindow::OnPaint() handler you draw the sub wxBitmap you store and iterate through the list of lines and draw them directly into the wxPaintDC. You may optionally draw to a wxMemoryDC's wxBitmap and store it, but remember that if they scroll you have to recreate it so this stored one would *only* be used if a portion of the window was covered and uncovered, so it's not much of an optimization. Have a side panel with a wxListCtrl, wxListBox, wxTreeCtrl type widget with the various lines you draw and allow the user to select or deselect them. Hope this helps, John ps. Maybe you could cut the single image into 4, 8, 16 pieces that you load and splice together. This way you would not have to load the whole image at once and if you wanted to show the whole image zoomed out you would load each one at a time scale down them down and splice them together which wouldn't take much memory at all. ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users