Problem with using System.Drawing.Bitmap

  • Thread starter John via .NET 247
  • Start date
J

John via .NET 247

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 andhas a large blue area on a particular side, which gets largerevery time the image is flipped again.

I'm assuming that this may be due to a lack of time assigned tothe procedure before saving the image, but I'm not sure how Ican 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
 

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,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top