Can't set background color in 4.2.5 on jpeg terminal

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't set background color in 4.2.5 on jpeg terminal

rodgilchrist
The following script produces a plot with a black background and a red trace on gnuplot 4.0.0, but produces a plot with a white background and red trace on gnuplot 4.5.2.

One from a fresh install on OSX 10.5.7 via Fink. The other from a fresh install via Macports. (As in both Fink and Macports were completely removed and both port systems reinstalled from scratch.)

Is this a known bug or a known library configuration issue?

Thanks.

- Rod

gnuplot > file.jpg  <<XXX
set term jpeg size 1200,90 x000000 xffffff x0000ff xff0000
set datafile separator ","
plot [0.01: 3] 'file.csv' using 1:2 notitle  with lines
XXX
Reply | Threaded
Open this post in threaded view
|

Re: Can't set background color in 4.2.5 on jpeg terminal

thse
has something to do with the fact that the gd-library
sets the background to black for truecolor graphics.
this is repaired by gnuplot's gd terminal by drawing
a white background and then plotting over it.
but the old mechnism for non-truecolor graphics (1st
color is background color) doesn't work anymore.

you can see this when plotting a png-file with
set term png notrue
or
set term png true

BTW, using the jpeg terminal for plots with colored
background gives you a really poor plot quality, due
to the lossy compression algorithm, see
(this plot was done with a patched version of gnuplot)

it is better to use the png or gif terminal.

<quote author="rodgilchrist">
The following script produces a plot with a black background and a red trace on gnuplot 4.0.0, but produces a plot with a white background and red trace on gnuplot 4.5.2.

One from a fresh install on OSX 10.5.7 via Fink. The other from a fresh install via Macports. (As in both Fink and Macports were completely removed and both port systems reinstalled from scratch.)

Is this a known bug or a known library configuration issue?

Thanks.

- Rod

gnuplot > file.jpg  <<XXX
set term jpeg size 1200,90 x000000 xffffff x0000ff xff0000
set datafile separator ","
plot [0.01: 3] 'file.csv' using 1:2 notitle  with lines
XXX

</quote>
Reply | Threaded
Open this post in threaded view
|

Re: Can't set background color in 4.2.5 on jpeg terminal

rodgilchrist
Perfect Thomas, thank you. Both gif and png terminals work.
Also the jpeg comment is right on.

Can I suggest that this is a bug in the jpeg terminal that I believe could be fixed by
changing line 1360 in gd.trm (PNG_graphics()) from:

        rgb = gdImageColorAllocate(png_state.image, 255, 255, 255);

to
        rgb = png_state.rgb_table[0];
        rgb = gdImageColorAllocate(png_state.image, (rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff);

The 'terminal jpeg' statement is loading the background color entry. Might as well just use it instead of a fixed white color.


- Rod


<quote author="Thomas Sefzick">
has something to do with the fact that the gd-library
sets the background to black for truecolor graphics.
this is repaired by gnuplot's gd terminal by drawing
a white background and then plotting over it.
but the old mechnism for non-truecolor graphics (1st
color is background color) doesn't work anymore.
Reply | Threaded
Open this post in threaded view
|

Re: Can't set background color in 4.2.5 on jpeg terminal

thse
i uploaded a patch on sourceforge yesterday which contains
your suggestion plus another correction (background color
of patterns):
http://sourceforge.net/tracker/?func=detail&aid=2809200&group_id=2055&atid=302055
(but for version 4.3 not for 4.2.x)

<quote author="rodgilchrist">
Perfect Thomas, thank you. Both gif and png terminals work.
Also the jpeg comment is right on.

Can I suggest that this is a bug in the jpeg terminal that I believe could be fixed by
changing line 1360 in gd.trm (PNG_graphics()) from:

        rgb = gdImageColorAllocate(png_state.image, 255, 255, 255);

to
        rgb = png_state.rgb_table[0];
        rgb = gdImageColorAllocate(png_state.image, (rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff);

The 'terminal jpeg' statement is loading the background color entry. Might as well just use it instead of a fixed white color.


- Rod


Thomas Sefzick wrote
has something to do with the fact that the gd-library
sets the background to black for truecolor graphics.
this is repaired by gnuplot's gd terminal by drawing
a white background and then plotting over it.
but the old mechnism for non-truecolor graphics (1st
color is background color) doesn't work anymore.