Published:
05 Dec 2003
|
Abstract
In this example we set the GIF to use a standard "web safe" non-dithering palette, using GDI+ and System.Drawing.
|
|
by Chris Garrett
Feedback
|
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days):
6640/
27
|
|
|
Saving an image with "Web Safe" Colors |
Saving an image with "Web Safe" Colours by Chris Garrett
Almost as soon as I posted my previous article on setting the palette and background transparency of a GIF I got emails from people asking to fill in the missing information - namely how to set the palette of the resulting image to something useful.
In this example we set the GIF to use a standard "web safe" non-dithering palette.
Before
After
View Source - /chrisg/tools/view-websafegif.vb.aspx - /chrisg/tools/view-websafegif.aspx.aspx
The code begins by loading in a bitmap that contains some reference pictures so we can compare the final result.
We then create a SortedList of web safe colours with three nested for .. next loops, using the fact that web safe colours are made up of a fixed set of values.
This fact also comes in handy with selecting the closest colour match, we simply select the closest value for each of the red, green and blue values.
Download - /chrisg/tools/download.asp?file=websafegif.aspx - /chrisg/tools/download.asp?file=websafegif.vb |
|
|
User Comments
No comments posted yet.
|
Product Spotlight
|
|