Hi all,
i want to show a image. for this i am using following code.
private void Display(string sFile)
{
try
{
Int16 iWidth = 0;
Int16 iHeight = 0;
System.Drawing. Image obBMP = new System.Drawing. Bitmap(sFile);
FileInfo obFileInfo = new FileInfo(sFile) ;
iWidth = Convert.ToInt16 (obBMP.Width);
iHeight = Convert.ToInt16 (obBMP.Height);
if (obBMP.Width > 100)
{
iWidth = 100;
iHeight = Convert.ToInt16 ((obBMP.Height * iWidth) / (obBMP.Width));
}
if (iHeight > 110)
{
iHeight = 110;
iWidth = Convert.ToInt16 ((obBMP.Width * iHeight) / (obBMP.Height)) ;
}
System.Drawing. Bitmap obBimMap = new System.Drawing. Bitmap(obBMP, iWidth, iHeight);
System.Drawing. Graphics oDraw = System.Drawing. Graphics.FromIm age(obBimMap);
Stream output = Response.Output Stream;
obBimMap.Save(o utput, System.Drawing. Imaging.ImageFo rmat.Bmp);
obFileInfo = null;
obBimMap.Dispos e();
obBimMap = null;
obBMP.Dispose() ;
obBMP = null;
}
catch (Exception)
{
throw;
}
}
This code is working fine for another of my project. But when i run this code in current project it occurs the error "A generic error occurred in GDI+."
I have also set all the permission of my project folder. But didn't get the reason of this problem.
i want to show a image. for this i am using following code.
private void Display(string sFile)
{
try
{
Int16 iWidth = 0;
Int16 iHeight = 0;
System.Drawing. Image obBMP = new System.Drawing. Bitmap(sFile);
FileInfo obFileInfo = new FileInfo(sFile) ;
iWidth = Convert.ToInt16 (obBMP.Width);
iHeight = Convert.ToInt16 (obBMP.Height);
if (obBMP.Width > 100)
{
iWidth = 100;
iHeight = Convert.ToInt16 ((obBMP.Height * iWidth) / (obBMP.Width));
}
if (iHeight > 110)
{
iHeight = 110;
iWidth = Convert.ToInt16 ((obBMP.Width * iHeight) / (obBMP.Height)) ;
}
System.Drawing. Bitmap obBimMap = new System.Drawing. Bitmap(obBMP, iWidth, iHeight);
System.Drawing. Graphics oDraw = System.Drawing. Graphics.FromIm age(obBimMap);
Stream output = Response.Output Stream;
obBimMap.Save(o utput, System.Drawing. Imaging.ImageFo rmat.Bmp);
obFileInfo = null;
obBimMap.Dispos e();
obBimMap = null;
obBMP.Dispose() ;
obBMP = null;
}
catch (Exception)
{
throw;
}
}
This code is working fine for another of my project. But when i run this code in current project it occurs the error "A generic error occurred in GDI+."
I have also set all the permission of my project folder. But didn't get the reason of this problem.
Comment