diff options
author | Ray Johnston <ray.johnston@artifex.com> | 2014-03-11 08:31:32 -0700 |
---|---|---|
committer | Ray Johnston <ray.johnston@artifex.com> | 2014-03-13 12:04:57 -0700 |
commit | c34097f6786f809826a30484e69684adf4915e9a (patch) | |
tree | 49180dd29e171cf02603ce9a76e3ef399b0a4d03 | |
parent | 685e801f7de04d087166e24b3373ab16dcca57bc (diff) | |
download | ghostpdl-c34097f6786f809826a30484e69684adf4915e9a.tar.gz |
Fix output color values of pkm and pkmraw for GrayValues > 2.
In the header we indicate the max value is 255, so the output values
need to be scaled to that, not the color_info.max_color. We stay with
255 since many viewers cannot display PPM files with other that 255
as the max (ignoring the max value in the header).
-rw-r--r-- | gs/devices/gdevpbm.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gs/devices/gdevpbm.c b/gs/devices/gdevpbm.c index 98090a7fe..9a926a877 100644 --- a/gs/devices/gdevpbm.c +++ b/gs/devices/gdevpbm.c @@ -1222,6 +1222,7 @@ pkm_print_row_4(gx_device_printer * pdev, byte * data, int depth, return 0; } /* Print a row where each pixel occupies 1 or more bytes (depth >= 8). */ +/* Note that the output is scaled up to 255 max value. */ static int pkm_print_row(gx_device_printer * pdev, byte * data, int depth, FILE * pstream) @@ -1229,7 +1230,6 @@ pkm_print_row(gx_device_printer * pdev, byte * data, int depth, gx_device_pbm * const bdev = (gx_device_pbm *)pdev; byte *bp; uint x; - ulong max_value = pdev->color_info.max_color; for (bp = data, x = 0; x < pdev->width;) { bits32 pixel = 0; @@ -1255,9 +1255,9 @@ pkm_print_row(gx_device_printer * pdev, byte * data, int depth, } ++x; pkm_map_color_rgb((gx_device *) pdev, pixel, rgb); - r = rgb[0] * max_value / gx_max_color_value; - g = rgb[1] * max_value / gx_max_color_value; - b = rgb[2] * max_value / gx_max_color_value; + r = rgb[0] * 0xff / gx_max_color_value; + g = rgb[1] * 0xff / gx_max_color_value; + b = rgb[2] * 0xff / gx_max_color_value; if (bdev->is_raw) { if (putc(r, pstream) == EOF) return_error(gs_error_ioerror); |