ygyu

ygyu

  • NA
  • 16
  • 0

why does this code throw the exception

Oct 14 2003 2:25 AM
the code is following which is to lock the bitmap data to memory and copy memory data to an array. 1: ImgStream = OpenImage.OpenFile(); 2: myImage = new Bitmap(ImgStream); 3: ImgFormat = myImage.PixelFormat; 4: rec = new Rectangle(0,0,myImage.Width,myImage.Height); 5: biData = myImage.LockBits(rec,ImageLockMode.ReadWrite,ImgFormat); 6: SrcWidthBytes = myImage.Width * 4; 7: SrcBytes = myImage.Width * myImage.Height * 4; 8: BmpData = new byte[SrcBytes]; 9: System.Runtime.InteropServices.Marshal.Copy(biData.Scan0,BmpData,0,SrcBytes); The statement which generate the exception is the ninth statement, but I can't understand why this statement throw the exception.

Answers (7)