Ali Alshihry

Ali Alshihry

  • NA
  • 23
  • 987

Error Out of memory when dealing with tiff images in c# 2015

Feb 16 2018 11:08 PM
Hello
 
I'm working on c#
 
Has a problem when dealing with images of type Tiff in the following code:
 
public static Bitmap ResizeImage(Image pic, int w, int h)
{
Bitmap returnImag = new Bitmap(w, h);
returnImag.SetResolution(pic.HorizontalResolution, pic.VerticalResolution);
using (Graphics graphics = Graphics.FromImage(returnImag))
{
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.DrawImage(pic, 0, 0, returnImag.Width, returnImag.Height);
}
return returnImag;
}
 
Note that if i put a message code to disable the implementation more than ten seconds between the image and the following image the previous code works
 
Do you have any suggestion to do code without placing a message
 
DialogResult result = MessageBox.Show("?? ???? ?????????????", " ????? ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{ }
 
Thank you

Answers (3)