-
bitmap blank
Hi , is there anything wrong with my code below? How come the image that is saved always a blank black image? vs. the image from the sFilePath?
Code:
Image img = Image.FromFile(sFilePath);
iUpHeight = img.Height;
iUpWidth = img.Width;
int iNewHeight = 300;
int iNewWidth = 450;
decimal reduce;
Bitmap upBmp = (Bitmap)(Bitmap.FromFile(sFilePath));
Bitmap bmp = new Bitmap(iNewWidth, iNewHeight);
if (iUpWidth > iUpHeight)
{
reduce = iNewWidth / iUpWidth;
iNewHeight = (int)(iUpHeight * reduce);
}
bmp.SetResolution(72, 72);
Graphics graphic = Graphics.FromImage(bmp);
graphic.DrawImage(upBmp, 0, 0, iNewWidth, iNewHeight);
graphic.Dispose();
bmp.Save(HttpContext.Current.Server.MapPath("~/Photos/test.jpg"));