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
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