Compressing image colors:

  • Thread starter Thread starter Fergus Cooney
  • Start date Start date
F

Fergus Cooney

Hi MC D,

Strange things happen. Only today I was browsing on a totally different
question and came across this

Color Quantization and GDI+ GIF with much better quality
This sample shows how to decrease colors in an image from 24bit to 8 bit. And
various other numbers of colors as well, from 8 to 256. Quantization is done
by using an octree. Many thanks to vbaccelerator.com.

GDI+ uses a halftone palette by default to save the image to file. This leads
to terrible quality in many cases. This sample greatly improves the saved GIF
image. Enjoy!

http://www.dotnetforums.net/t74693.html


Regards,
Fergus
 
I have a aspx page that outputs an image to the response.outputstream. This
works great. However, I want to be able to make the image it outputs a .gif
file. I can change the output type to "image/gif" and save the image by
doing:

myBitmap.Save(response.outputstream,ImageFormat.Gif)
and this works, BUT it uses a horrible halftone palette to reduce the
colors. I have been trying for a day and a half to figure out any way to
reduce the colors into a .gif with no success. You can see the articles at:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q319591 and
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q319061 which
actually work, but only in grayscale. Does anyone have any ideas of a way to
do this?

OR

I have also tried outputting the file as a PNG, which works, but because
(for whatever reason), the png always comes out darker than the original,
and I need the background color of my image to match the background color on
the site. SOOOooo... If someone can tell me how to make a background color
of a png transparent, programmatically, that might work too.

Thanks for any help!!!
 
MC D said:
I have a aspx page that outputs an image to the response.outputstream. This
works great. However, I want to be able to make the image it outputs a .gif
file. I can change the output type to "image/gif" and save the image by
doing:

myBitmap.Save(response.outputstream,ImageFormat.Gif)
and this works, BUT it uses a horrible halftone palette to reduce the
colors. I have been trying for a day and a half to figure out any way to
reduce the colors into a .gif with no success. You can see the articles at:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q319591 and
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q319061 which
actually work, but only in grayscale. Does anyone have any ideas of a way to
do this?

OR

I have also tried outputting the file as a PNG, which works, but because
(for whatever reason), the png always comes out darker than the original,
and I need the background color of my image to match the background color on
the site. SOOOooo... If someone can tell me how to make a background color
of a png transparent, programmatically, that might work too.

Thanks for any help!!!

If you are using MSIE to view the images, they appear darker because
MSIE mishandles the gamma data. Try removing the gAMA chunk and
using only the sRGB chunk, and see if the color level is better.
You can use the pngcrush application from an MSDOS window to do this.

pngcrush -rem gama -srgb 1 in.png temp.png

Get pngcrush from the DOWNLOAD link at http://pmt.sf.net/pngcrush

Glenn
 
Back
Top