Groups | Blog | Home
all groups > dotnet drawing api > january 2005 >

dotnet drawing api : Issues rotating an image - Where did my DrawArc() go?


awbacker NO[at]SPAM gmail.com
1/25/2005 6:18:33 PM
I am having a funny issue with rotating an image. I am modifying the
code that creates a rounded corner image, and it appears that the arc
that it draws is getting 'lost' during rotation.

I have no problems with the straight lines that I draw, but the arc
(when flipping x) gets pushed left 5 pixes, and when flipping Y it
disappears altogether.
The code looks something like this :

Bitmap bmp = new Bitmap(20,20);
Graphics gfx = Graphics.FromImage(bmp);
gfx.SmoothingMode = HighQuality;
gfx.Clear(white);
gfx.DrawArc( black brush, ....)
gfx.DrawLine( black brush, 0,0,10,10);
// -- point 1 ---
bmp.RotateFlip( RotateNoneFlipX );
// -- point 2 ---
bmp.RotateFlip( RotateNoneFlipXY);
// -- point 3 --




I save my image at all 3 locations (lets just say.). Now, at point 1, I
see a proper arc & line. At point 2 I see the line perfectly flipped,
but the arc is offset to the left by about 5 pixels. At point 3 I see
the line I drew, but the arc is gone completely.

Any ideas what is going on here? The documentation is pretty poor about
possible issues with drawing orders, etc.

I have tried flush()ing, flush( with intention), save()ing, etc, and
anything else I can think of. The first one is the only one that is
okSad

Thanks for any help,
Andrew Backer
awbacker NO[at]SPAM gmail.com
1/26/2005 8:47:21 AM
I knew that this would happen, even though I thought I had been careful
and checked :( There is no problem with the drawing code, there was
something I didn't see changing the coordinates that the arc was drawn
at. Still not sure exactly why it worked the way it did, but it did.

Thanks for running the code! I had really settled in on the idea that
it was gdi messing up because the arc was being rotated/flipped, and
you saved me.
btw. I am just using Image.Save(..., Gif).

- Andrew Backer
Mick Doherty
1/26/2005 11:01:17 AM
I don't see any such problem using the following code:

\\\
Bitmap bmp = new Bitmap(20,20);
Graphics gfx = Graphics.FromImage(bmp);
gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gfx.Clear(Color.White);
gfx.DrawArc(Pens.Black,0,0,10,10,45,180);
gfx.DrawLine(Pens.Black, 0,0,10,10);
pictureBox1.Image=new Bitmap(bmp);
bmp.RotateFlip( System.Drawing.RotateFlipType.RotateNoneFlipX );
pictureBox2.Image=new Bitmap(bmp);
bmp.RotateFlip( System.Drawing.RotateFlipType.RotateNoneFlipXY);
pictureBox3.Image=new Bitmap(bmp);
///

Where are you drawing the arc? How are you saving the image?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


[quoted text, click to view]

AddThis Social Bookmark Button