Use octreequantizer to Improve the Quality of GDI + plotting

Source: Internet
Author: User

In. net, the quality of graphics drawn by GDI + is very small, because GDI + uses 256 colors.

The "REE" algorithm can be used to improve the image quality. The "REE" algorithm allows us to insert our own algorithms to quantize our images.

A good "Color quantization" algorithm should consider filling the two pixel particles with a transitional color similar to the two pixels to provide more visible color space.

Morgan Skinner provides good "REE" algorithm code. You can download it for reference.

It is convenient to use octreequantizer:

Public byte [] draw ()
{
System. Drawing. bitmap image = new system. Drawing. Bitmap (this. imagewidth, this. imageheight );
Graphics G = graphics. fromimage (image );
G. smoothingmode = smoothingmode. highquality;
G. interpolationmode = interpolationmode. highqualitybicubic;

// Draw an image
This. renerimage (g );
System. Io. memorystream MS = new system. Io. memorystream ();

// use octreequantizer to clear images
octreequantizer oqt = new octreequantizer (255, 8);
system. drawing. bitmap highimage = oqt. quantize (image);
highimage. save (MS, system. drawing. imaging. imageformat. GIF);
byte [] buffer = Ms. toarray ();
G. dispose ();
image. dispose ();
highimage. dispose ();
return buffer;
}

    • Octreequantizer.zip (6.6 KB)

Use octreequantizer to Improve the Quality of GDI + plotting

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.