Asp.net improves the quality of GIF images with color changes

Source: Internet
Author: User
Tags transparent image

Tutorial on bkjia.com. netIn asp.net, the GDI + has a strong image operation function and good effect. However, when you output GIF images, you will find that the image quality is poor, and the output JPG, comparing PNG and BMP formats, there is a big gap and the image effect is somewhat unacceptable.

Here is a method provided by Microsoft's MSDN to improve the effect of the generated GIF image. To improve the quality of jpg, I am in. NET high-quality thumbnails, transparent image watermarks, text watermarks Source Code released in the article, has provided the implementation method, this is not involved here.

Improve the effect of GIF Image Generation. Here we use color quantization, that is, the color-colored palette of the duplicate plot.

Let's take a look at several comparison images:


Original Image

 
Image generated by asp.net by default

 
Color quantified Image

After Color quantization, we can see that the effect is already quite good.

This Color quantization class library is also very simple:

Reference content is as follows:
Using (Bitmap bmp = new Bitmap (...)) {OctreeQuantizer quantizer = new OctreeQuantizer (255, 8); // two parameters are the color value and the color depth using (Bitmap quantized = quantizer. quantize (image) {Response. contentType = "image/gif"; quantized. save (Response. outputStream, ImageFormat. gif );}}

This library comes from MSDN, the original address: http://msdn.microsoft.com/en-us/library/aa479306.aspx

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.