My gifs are too noisy
I need some help. I wrote some code to pull some images from a database and write them on a web page. Nothing special, the code is working well, except for one very annoying thing.
The pictures in Gif format come out with some noise (see example), dithered if you prefer. I know how to fix the problem for the images I create myself using a Graphics object but I can't figure out how to solve this one.
The JPeg are fine, but I am stuck with the Gifs.
I am sure it has something to do with ContentType, because my data is in a Stream, so obviously has to know the mime type to render the right format.
I tried this, but no success (the code is longer than that, but I removed the database part):
Dim bmp As Bitmap= New Bitmap(Processtoretrievemypicture)HttpContext.Current.Response.ContentType = "image/gif"
bmp.Save(HttpContext.Current.Response.OutputStream, ImageFormat.Gif)
If only I could use the same method as I did before with a Graphics object like this:
Dim g As System.Drawing.Graphics
g.TextRenderingHint = TextRenderingHint.AntiAlias
This was the right solution but now I don't find a way to associate this with my Stream. I got this error message:
A Graphics object cannot be created from an image that has an indexed pixel formatBy the way I found also a nice GDI+ Faq.