JPEG are real colour graphics (for example RGB). GIF are indexed colour
graphics with a maximum of 256 colours. Converting from one format to the
other is not as simple as loosing colur quality. In RVB format, three values
are used to represent each colour, for example 8 bits for Red, 8 bits for
Green and 8 bits for Blue. (There are other formats too.).
GIF use a palette of 2 to 256 colours. Each pixel is determined by a value
(8 bits for a 256 colours palette) representing one entry in the palette.
So, to convert from JPEG to GIF, you have to :
1) determine the most useful 256 colours or choose a standard palette (web
palette, for example)
2) match each pixel with a colour in the palette. There are many ways to
achieve this, from nearest value (you have to average "nearness" between the
primary colours) to dithering.
So, you have to convert to palette colour before sending graphics to Gif
encoder.
For more information, you should look to the JDK documentation (class
ColorModel)
Pierre-Yves Saumont
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
Terry Griffiths
Envoyé : jeudi 15 mars 2001 23:52
À : [EMAIL PROTECTED]
Objet :
Hello,
can anybody tell me if the acme gifencoder will encode jpeg to gif?
And if so, why am I getting a "too many colors for a gif" exception thrown?
(I always thought that the change from jpeg to gif would only mean a loss in
color quality)
Regards,
Ter.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html