Image passing
-
The following code crashes when I try to pass an image ______________________________________________________________________________ private void zoomin_Click(object sender, System.EventArgs e) { dxfviewer.Image =ScaleByPercent(dxfviewer.Image,50); }//end function static Image ScaleByPercent(Image imgPhoto, int Percent) { float nPercent = ((float)Percent/100); int sourceWidth = imgPhoto.Width; //with is null when passed this way int sourceHeight = imgPhoto.Height; int sourceX = 0; int sourceY = 0; _____________________________________________________________________________ Any thoughts on why this happens. Thanks
-
The following code crashes when I try to pass an image ______________________________________________________________________________ private void zoomin_Click(object sender, System.EventArgs e) { dxfviewer.Image =ScaleByPercent(dxfviewer.Image,50); }//end function static Image ScaleByPercent(Image imgPhoto, int Percent) { float nPercent = ((float)Percent/100); int sourceWidth = imgPhoto.Width; //with is null when passed this way int sourceHeight = imgPhoto.Height; int sourceX = 0; int sourceY = 0; _____________________________________________________________________________ Any thoughts on why this happens. Thanks
Reanalyse wrote: imgPhoto.Width; //with is null when passed this way You need to add code to check if imgPhoto is null then, in which case, you have no image to scale and need to just return null. Christian Graus - Microsoft MVP - C++