On Friday 07 October 2005 05:07 am, Shigeharu TAKENO wrote:
> shige 10/07 2005
> ----------------
>
> The following patch do use small number of colors in gd.trm.
Could you please explain why or when this is needed?
The current png driver (really libgd itself) only
stores the colors actually used by the plot.
For example:
gnuplot> set term png lw 2
gnuplot> set output 'colors.png'
gnuplot> plot sin(x),cos(x),x,x**2
gnuplot> quit
# identify -verbose colors.png
Image: colors.png
Format: PNG (Portable Network Graphics)
Geometry: 640x480
Class: DirectClass
Type: palette with transparency
Depth: 8 bits-per-pixel component
Colors: 13
2489: ( 0, 0, 0, 0) black
228: ( 31, 31, 31, 0) grey12
265: ( 63, 63, 63, 0) #3F3F3F00
161: ( 95, 95, 95, 0) #5F5F5F00
244: (127,127,127, 0) grey50
581: ( 0,192, 0, 0) #00C00000
554: ( 0,128,255, 0) #0080FF00
527: (255, 0, 0, 0) red
846: (192, 0,255, 0) #C000FF00
150: (159,159,159, 0) #9F9F9F00
147: (191,191,191, 0) grey75
234: (223,223,223, 0) #DFDFDF00
300774: (255,255,255, 0) grey100
Resolution: 72x72 pixels
You may ask why are there 13 colors rather than 6?
We requested white background, black text,
red, green, blue, magenta plot lines.
It is because antialiasing of the text to make it look smoother
introduces some grey pixels.
If I had not specified "lw 2" in the "set term png" command
there would also have been anti-aliasing of the colored lines,
which would have introduced additional colors.
> Although png term use 256 colors even if the number of colors was
> given explicitly, the colorloop option tells gnuplot to use only
> specified colors.
The png output only stores 256 colors if you create a plot that
uses 256 colors. That is primarily true for plots using the
pm3d palette. But any number of colors up to 256 still uses a
1-byte color index for each pixel ("Depth" in the output shown above).
So even in the case of pm3d images, reducing the colors to fewer than
256 will degrade the image while saving almost no space in the output
file.
It is true that if you generate 24-bit color images by explicitly
requesting "set term png truecolor", then it requires more storage
space. In this case there are 24 bits of color information per pixel
rather than 8 bits, so the output file will be roughly 3 times as large.
--
Ethan A Merritt merritt@...
Biomolecular Structure Center
Mailstop 357742
University of Washington, Seattle, WA 98195
|