Problem with using System.Drawing.Bitmap

G

Guest

Hi,

I'm using the System.Drawing.Bitmap namespace to load an image, and the
RotateNoneFlipY method to flip that image before saving. However I have
noticed that the saved image appears cropped and has a large blue area on a
particular side, which gets larger every time the image is flipped again.

I'm assuming that this may be due to a lack of time assigned to the
procedure before saving the image, but I'm not sure how I can recitify this.

I have attached the code below:

string fl;
System.Drawing.Image i;

fl = [FILENAME];
i = System.Drawing.Image.FromFile(fl);

System.Drawing.Bitmap ph = new System.Drawing.Bitmap(i.Height, i.Width,
PixelFormat.Format24bppRgb);

Graphics g;
g = Graphics.FromImage(ph);
g.Clear(Color.Blue);

i.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipY);

g.DrawImage(i, new Point(0,0));

try
{
Response.ContentType="image/jpeg";
ph.Save(Response.OutputStream, ImageFormat.Jpeg);
ph.Save([FILENAME2], ImageFormat.Jpeg);
ph.Dispose();
i.Dispose();

if(File.Exists(FILENAME))
{
File.Delete(FILENAME)
}

File.Copy(FILENAME2, FILENAME);
}
catch(Exception exc)

Response.Write(exc.Message+"<br>"+exc.Source+"<br>"+exc.StackTrace+"<br>"+exc.TargetSite);
}


Any help will be gratefully appreciated,

Thanks

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top