![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi, i've created a canvas like surface on which user can place some objects named frames. this frames can be resized, moved and filled with text or images. i have a problem with artifacts that appear on a drawing surface when user quickly moves or scales these frames. i can't afford invalidating whole canvas surface (drawing images is very expensive) so i can only invalidate the frame area. everything works fine but only when user performs slow movements. when the drag move is faster i get lots of artifacts that are not redrawn. when and how should i invalidate to prevent this? i've even created a "safe frame" that is sort of bounding box that is larger than the frame itself to have a bit larger invalidation area, but still this does not help for very fast movement. is the periodic invalidation of the whole drawing surface a reasonable solution? |
#3
| |||
| |||
|
|
hi, i've created a canvas like surface on which user can place some objects named frames. this frames can be resized, moved and filled with text or images. i have a problem with artifacts that appear on a drawing surface when user quickly moves or scales these frames. i can't afford invalidating whole canvas surface (drawing images is very expensive) so i can only invalidate the frame area. everything works fine but only when user performs slow movements. when the drag move is faster i get lots of artifacts that are not redrawn. when and how should i invalidate to prevent this? i've even created a "safe frame" that is sort of bounding box that is larger than the frame itself to have a bit larger invalidation area, but still this does not help for very fast movement. is the periodic invalidation of the whole drawing surface a reasonable solution? |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
You say that drawing images is expensive but have you ensured that ALL images are 32bppPargb? If not, do that! You really must invalidate the union of the -from- and -to- rectangles for any paint to work correctly. |
#6
| |||
| |||
|
|
"Bob Powell [MVP]" wrote : You really must invalidate the union of the -from- and -to- rectangles for any paint to work correctly." Hi Bob, I'm curious if this would also apply to a scenario in which the user is dragging/moving a picturebox around at run-time... rather than moving something drawn directly on a form or control surface with brushes or whatever ... as I think this scenario implies. thanks, Bill Woodruff |
#7
| |||
| |||
|
thanks bob. as usual - you are the best ![]() invalidation thing with union really helped. i must admit - it's soooo simple solution and works just great! as to bitmaps - i'm almost sure that they were not 32bppPArgb. i did some modifications and now am creating only 32bppPArgb bitmaps and the drawing speed seems to be indeed better. i have one question about that 32bppPArgb thing. is there any straightforward way of converting images loaded from files into that format? for now i do something like this: Bitmap finalImg = new Bitmap(tSize.Width, tSize.Height, PixelFormat.Format32bppPArgb); using(Graphics g = Graphics.FromImage(finalImage)) g.DrawImage(img,new Rectangle(new Point(0,0),tSize)); img.Dispose(); Bob Powell [MVP] wrote: You say that drawing images is expensive but have you ensured that ALL images are 32bppPargb? If not, do that! You really must invalidate the union of the -from- and -to- rectangles for any paint to work correctly. |
#8
| |||
| |||
|
|
You say that drawing images is expensive but have you ensured that ALL images are 32bppPargb? If not, do that! |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |