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