| OLD | NEW |
| 1 /* | 1 /* |
| 2 * wrppm.c | 2 * wrppm.c |
| 3 * | 3 * |
| 4 * Copyright (C) 1991-1996, Thomas G. Lane. | 4 * Copyright (C) 1991-1996, Thomas G. Lane. |
| 5 * Modified 2009 by Guido Vollbeding. |
| 5 * This file is part of the Independent JPEG Group's software. | 6 * This file is part of the Independent JPEG Group's software. |
| 6 * For conditions of distribution and use, see the accompanying README file. | 7 * For conditions of distribution and use, see the accompanying README file. |
| 7 * | 8 * |
| 8 * This file contains routines to write output images in PPM/PGM format. | 9 * This file contains routines to write output images in PPM/PGM format. |
| 9 * The extended 2-byte-per-sample raw PPM/PGM formats are supported. | 10 * The extended 2-byte-per-sample raw PPM/PGM formats are supported. |
| 10 * The PBMPLUS library is NOT required to compile this software | 11 * The PBMPLUS library is NOT required to compile this software |
| 11 * (but it is highly useful as a set of PPM image manipulation programs). | 12 * (but it is highly useful as a set of PPM image manipulation programs). |
| 12 * | 13 * |
| 13 * These routines may need modification for non-Unix environments or | 14 * These routines may need modification for non-Unix environments or |
| 14 * specialized applications. As they stand, they assume output to | 15 * specialized applications. As they stand, they assume output to |
| (...skipping 18 matching lines...) Expand all Loading... |
| 33 #if BITS_IN_JSAMPLE == 8 | 34 #if BITS_IN_JSAMPLE == 8 |
| 34 #define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) | 35 #define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) |
| 35 #define BYTESPERSAMPLE 1 | 36 #define BYTESPERSAMPLE 1 |
| 36 #define PPM_MAXVAL 255 | 37 #define PPM_MAXVAL 255 |
| 37 #else | 38 #else |
| 38 #ifdef PPM_NORAWWORD | 39 #ifdef PPM_NORAWWORD |
| 39 #define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) | 40 #define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) |
| 40 #define BYTESPERSAMPLE 1 | 41 #define BYTESPERSAMPLE 1 |
| 41 #define PPM_MAXVAL 255 | 42 #define PPM_MAXVAL 255 |
| 42 #else | 43 #else |
| 43 /* The word-per-sample format always puts the LSB first. */ | 44 /* The word-per-sample format always puts the MSB first. */ |
| 44 #define PUTPPMSAMPLE(ptr,v) \ | 45 #define PUTPPMSAMPLE(ptr,v) \ |
| 45 { register int val_ = v; \ | 46 { register int val_ = v; \ |
| 47 *ptr++ = (char) ((val_ >> 8) & 0xFF); \ |
| 46 *ptr++ = (char) (val_ & 0xFF); \ | 48 *ptr++ = (char) (val_ & 0xFF); \ |
| 47 *ptr++ = (char) ((val_ >> 8) & 0xFF); \ | |
| 48 } | 49 } |
| 49 #define BYTESPERSAMPLE 2 | 50 #define BYTESPERSAMPLE 2 |
| 50 #define PPM_MAXVAL ((1<<BITS_IN_JSAMPLE)-1) | 51 #define PPM_MAXVAL ((1<<BITS_IN_JSAMPLE)-1) |
| 51 #endif | 52 #endif |
| 52 #endif | 53 #endif |
| 53 | 54 |
| 54 | 55 |
| 55 /* | 56 /* |
| 56 * When JSAMPLE is the same size as char, we can just fwrite() the | 57 * When JSAMPLE is the same size as char, we can just fwrite() the |
| 57 * decompressed data to the PPM or PGM file. On PCs, in order to make this | 58 * decompressed data to the PPM or PGM file. On PCs, in order to make this |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 dest->pixrow = (JSAMPROW) dest->iobuffer; | 260 dest->pixrow = (JSAMPROW) dest->iobuffer; |
| 260 dest->pub.buffer = & dest->pixrow; | 261 dest->pub.buffer = & dest->pixrow; |
| 261 dest->pub.buffer_height = 1; | 262 dest->pub.buffer_height = 1; |
| 262 dest->pub.put_pixel_rows = put_pixel_rows; | 263 dest->pub.put_pixel_rows = put_pixel_rows; |
| 263 } | 264 } |
| 264 | 265 |
| 265 return (djpeg_dest_ptr) dest; | 266 return (djpeg_dest_ptr) dest; |
| 266 } | 267 } |
| 267 | 268 |
| 268 #endif /* PPM_SUPPORTED */ | 269 #endif /* PPM_SUPPORTED */ |
| OLD | NEW |