Image loading and releasing
If the image is loaded again, an error is reported. This method can avoid this problem.
Method 1:
1. Use bitmapPIC to obtain the bitmap object of the image from the file.
2. Then Clone a bitmap object Bitmap bmpCrop = bitmapPIC. Clone ();
3. Release the bitmapPIC object. No conflict will occur.
4.bmp Crop objects will be released after the function is run. Memory is not affected
Method 2:
// Read the file stream
FileStream fileStream = new FileStream (ClientFileFullName, FileMode. Open, FileAccess. Read); // ClientFileFullName is the path
Int byteLength = (int) fileStream. Length;
Byte [] fileBytes = new byte [byteLength];
FileStream. Read (fileBytes, 0, byteLength );
// Close the file stream and unlock the file
FileStream. Close ();
Image img = Image. FromStream (new MemoryStream (fileBytes); // load the Image