On Tue, 19 Feb 2008 11:22:55 -0800,
al*****@altavista.com
<al*****@altavista.comwrote:
[...]
The only thing I notice is that the gif result looks a bit light. That
why I want some review of this approach. Perhaps I'm missing/
overlooking something - so any comments/suggestions that you may like
to offer me would be most appreciated.
Unless you want to do a lot of extra work, I think the method you're using
is about as good as you're going to get, at least with respect to the
color (there are higher-quality ways to resample the resolution of the
image, but you don't appear concerned about that).
GIF supports palettized images. If you start with a non-palettized image,
then .NET has to convert. This will necessarily reduce the color space
available and cause some discoloration of the image. It won't always be
"lighter", but it will always be different.
If you can preprocess the image so that it's only 8-bit palettized before
converting to a GIF, then you should get better results, at least with
respect to the saved GIF matching the bitmap just before saving. But
solving this in a general way is non-trivial, and for optimal results
requires some interaction with the user, who is the only person who can
tell your code whether the reduced-color image "looks right".
You might want to play with a full-blown image editing application (e.g.
Photoshop, GIMP, etc.) that can do image format conversions to see what
happens when you palettize non-palettized images. Even in Photoshop (or
Photoshop Elements), the most popular, widely used program, a GIF never
looks quite as nice as an original 24-bit image.
You don't say what you're using the GIF output for, but for what it's
worth, the PNG format offers in some respects the best of both worlds: the
non-lossy compression and support of transparency of GIF with the
full-color support of JPEG. Your file size will be larger than for GIF,
but it doesn't look like you're dealing with very large files to start
with, and the quality will be much better.
Pete