When. net generates thumbnails and watermark images, a general error occurs in GDI +. netgdi

Source: Internet
Author: User
Tags watermark images

When. net generates thumbnails and watermark images, a general error occurs in GDI +. netgdi

Copy codeThe Code is as follows:
System. Drawing. Image OldImage = null;
OldImage = System. Drawing. Image. FromFile (ImageUrl );

 
When you use this method to read images. As a result, the resources cannot be released due to a deadlock in the image file, and a general error occurs when the imported resource is overwritten.
 
Solution: change the code to the following code:

Copy codeThe Code is as follows:
Bitmap oImage = new Bitmap (ImageUrl); // read the image stream from the image file
Bitmap OldImage = new Bitmap (oImage); // copy the image stream to the new image stream
OImage. Dispose (); // release the original image stream and unlock the image file.

It is very simple and practical. If you have any questions, refer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.