|I'm designing a small vector graphics app. Right now I'm writing code for painting a shape as it's being moved. For move operations, the shape is painted to a bitmap buffer so refreshes can be more effecient. Everything is working fine except when the drawing surface is scaled (zoomed).
The scaling factor is applied to the Graphics object when a paint message is called. That scaling factor is also used to generate a scaled "move bitmap" for the shape. For example, if the physical size of the shape is: 100 x 100 and the scaling factor is 50% then the move bitmap will be 50 x 50. The bitmap is then drawn as unscaled.
The problem is that the DrawImageUnscaled() method is not working! I get the same scaled results as if I were calling the DrawImage() method. This is rendering the scaled "move bitmap" to an additionaly scaled size!
Has anyone experienced this before?
private void initMoveBitmap()
//if the scaling factor is .50 the GetScaledBounds will produce a 50x50 on a 100x100 size
Rectangle r = shape.GetScaledBounds();
bmpMove = new Bitmap(r.Width, r.Height);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmpMove);
gr = null;
public void PaintShape(Graphics g)
//scenario: the graphics object has a scaling factor of .50
if (bmpMove != null)
//produces no difference from the DrawImage() method
//paint the shape.. (code excluded)
My code this week has no errors. But it's Monday morning and I haven't got out of bed.