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