[Mono-dev] Bitmap manipulation - am I doing it right?

Stifu stifu at free.fr
Tue Mar 31 09:27:52 EDT 2009


Hi Andreas,

Thanks for your reply.

The size and the color of the rectangle can vary, and it can also be
semi-transparent, so I'm not sure making it a control is possible.
Your second idea is interesting, though, I'll have to try it.

By the way, I also wanted to clone because I show a small part of a big
image (and you can scroll through the Panel to show the other parts), and
didn't want to draw anything too big on my Panel ("too big" as in, bigger
than the Panel size, so out of bounds). So I actually have 2 Bitmaps in
memory: the whole image, and the partial (on-screen) image, and so I simply
clone the latter each time and update it when necessary (ie: when you scroll
or resize the window).
Your solution would be helpful when hovering the image to draw the rectangle
(which was fast already), but not when scrolling through the Panel (the
slowest part)... Not sure if I can do anything to make scrolling faster.


Andreas Nahr wrote:
> 
> What you are doing is very inefficient.
> Two ideas:
> 1) Don't directly draw onto the image if you are only want so show
> something
> to the user and not really want to manipulate the image. You could easily
> use a rectangle control and show that above the image control.
> 2) Before you paint the rectangle copy the overpainted area into a
> temporary
> image. Then draw the rectangle. To (re)move the rectangle copy the data
> back
> from the temporary image (do not copy the entire image or create a new
> one)
> 
> Andreas
> 
> -----Ursprüngliche Nachricht-----
> Von: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] Im Auftrag von Stifu
> Gesendet: Dienstag, 31. März 2009 10:10
> An: mono-devel-list at lists.ximian.com
> Betreff: [Mono-dev] Bitmap manipulation - am I doing it right?
> 
> 
> Hello,
> 
> I have an application that displays graphics, stored in a Bitmap.
> When you hover the concerned Panel, a square shows what tile you're
> currently highlighting. So if you move your cursor, the square moves too.
> 
> What I'm doing is, each time I repaint my Panel, clone the Bitmap then
> draw
> the rectangle (square) on it. If I didn't clone it first and worked
> directly
> with the original Bitmap, then the squares would never go away, and keep
> on
> multiplying as you move your cursor over the Panel.
> So I'm just wondering: is cloning the right thing to do here? Or is there
> a
> better / more efficient way to achieve the same results, like some kind of
> temporary modifications to a Bitmap or whatever? (I'm using double
> buffering, so everything has to be on the same Bitmap)
> 
> I already implemented clipping to improve performances, but I wanted to
> know
> if there was anything else I could do... Thanks.
> -- 
> View this message in context:
> http://www.nabble.com/Bitmap-manipulation---am-I-doing-it-right--tp22800298p
> 22800298.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 

-- 
View this message in context: http://www.nabble.com/Bitmap-manipulation---am-I-doing-it-right--tp22800298p22804927.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list