Optimizing rendered image
I realized the png I render the text to will end up with color matching issues (I've found this in general with some pngs).
I found a cool way to have it render a gif with an optimized palette using some code from Morgan Skinner who wrote an article “Optimizing Color Quantization for ASP.NET Images”.
Add this dll to your references:
ImageManipulation.dll
now with "using ImageManipulation;"
you can change the line textImage.Save(memStream, System.Drawing.Imaging.ImageFormat.Png); in the code I wrote earlier to:
OctreeQuantizer quantizer = new OctreeQuantizer(255, 8);
Bitmap quantized = quantizer.Quantize(textImage);
Response.ContentType = "image/gif";
quantized.Save(memStream, ImageFormat.Gif);
You can see this working on here. The titles in the orange and brown boxes are images.
I found a cool way to have it render a gif with an optimized palette using some code from Morgan Skinner who wrote an article “Optimizing Color Quantization for ASP.NET Images”.
Add this dll to your references:
ImageManipulation.dll
now with "using ImageManipulation;"
you can change the line textImage.Save(memStream, System.Drawing.Imaging.ImageFormat.Png); in the code I wrote earlier to:
OctreeQuantizer quantizer = new OctreeQuantizer(255, 8);
Bitmap quantized = quantizer.Quantize(textImage);
Response.ContentType = "image/gif";
quantized.Save(memStream, ImageFormat.Gif);
You can see this working on here. The titles in the orange and brown boxes are images.
Labels: 256, gif, image, optimization, optimize, palette, render, server
