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