example.c: Write correct dimensions to PPM header

The dimensions in the PPM header of the output file generated by
'example decompress' were always 640 x 480, regardless of the size of
the JPEG image being decompressed.  Our regression tests (which this
commit also fixes) missed the bug because they decompressed the
640 x 480 image generated by 'example compress'.

Fixes #778
This commit is contained in:
DRC
2024-08-02 08:45:36 -04:00
parent 0566d51e09
commit 8db0312668
2 changed files with 5 additions and 7 deletions

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software.
* Copyright (C) 1992-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2017, 2019, 2022-2023, D. R. Commander.
* Copyright (C) 2017, 2019, 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -443,7 +443,7 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
*/
/* emit header for raw PPM format */
fprintf(outfile, "P6\n%d %d\n%d\n", WIDTH, HEIGHT,
fprintf(outfile, "P6\n%u %u\n%d\n", cinfo->image_width, cinfo->image_height,
cinfo->data_precision == 12 ? MAXJ12SAMPLE : MAXJSAMPLE);
/* Step 4: set parameters for decompression */