Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 355025 | Differences between
and this patch

Collapse All | Expand All

(-)netpbm-10.51.00/converter/other/pamrgbatopng.c.orig (-4 / +6 lines)
Lines 101-110 Link Here
101
    if (!infoP)
101
    if (!infoP)
102
        pm_error("Could not allocate PNG info structure");
102
        pm_error("Could not allocate PNG info structure");
103
    else {
103
    else {
104
        infoP->width      = pamP->width;
104
    	png_set_IHDR(pngP, infoP,
105
        infoP->height     = pamP->height;
105
			pamP->width, pamP->height, 8,
106
        infoP->bit_depth  = 8;
106
			PNG_COLOR_TYPE_RGB_ALPHA,
107
        infoP->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
107
			PNG_INTERLACE_NONE,
108
			PNG_COMPRESSION_TYPE_DEFAULT,
109
			PNG_FILTER_TYPE_DEFAULT);
108
        
110
        
109
        png_init_io(pngP, ofP);
111
        png_init_io(pngP, ofP);
110
112
(-)netpbm-10.51.00/converter/other/pngtxt.c.orig (-10 / +12 lines)
Lines 240-251 Link Here
240
240
241
241
242
void 
242
void 
243
pnmpng_read_text (png_info * const info_ptr, 
243
pnmpng_read_text (struct pngx* const pngxP, 
244
                  FILE *     const tfp, 
244
                  FILE *     const tfp, 
245
                  bool       const ztxt,
245
                  bool       const ztxt,
246
                  bool       const verbose) {
246
                  bool       const verbose) {
247
247
248
    const char * textline;
248
    const char * textline;
249
    struct png_text_struct* text;
249
    unsigned int lineLength;
250
    unsigned int lineLength;
250
    unsigned int commentIdx;
251
    unsigned int commentIdx;
251
    bool noCommentsYet;
252
    bool noCommentsYet;
Lines 257-264 Link Here
257
258
258
    allocatedComments = 256;  /* initial value */
259
    allocatedComments = 256;  /* initial value */
259
260
260
    MALLOCARRAY(info_ptr->text, allocatedComments);
261
    MALLOCARRAY(text, allocatedComments);
261
    if (info_ptr->text == NULL) 
262
    if (text == NULL) 
262
        pm_error("unable to allocate memory for comment array");
263
        pm_error("unable to allocate memory for comment array");
263
264
264
    commentIdx = 0;
265
    commentIdx = 0;
Lines 273-279 Link Here
273
            if (lineLength == 0) {
274
            if (lineLength == 0) {
274
                /* skip this empty line */
275
                /* skip this empty line */
275
            } else {
276
            } else {
276
                handleArrayAllocation(&info_ptr->text, &allocatedComments,
277
                handleArrayAllocation(&text, &allocatedComments,
277
                                      commentIdx);
278
                                      commentIdx);
278
                if ((textline[0] != ' ') && (textline[0] != '\t')) {
279
                if ((textline[0] != ' ') && (textline[0] != '\t')) {
279
                    /* Line doesn't start with white space, which
280
                    /* Line doesn't start with white space, which
Lines 285-291 Link Here
285
                        ++commentIdx;
286
                        ++commentIdx;
286
                    noCommentsYet = FALSE;
287
                    noCommentsYet = FALSE;
287
288
288
                    startComment(&info_ptr->text[commentIdx], 
289
                    startComment(&text[commentIdx], 
289
                                 textline, lineLength, ztxt);
290
                                 textline, lineLength, ztxt);
290
                } else {
291
                } else {
291
                    /* Line starts with whitespace, which means it is
292
                    /* Line starts with whitespace, which means it is
Lines 295-301 Link Here
295
                        pm_error("Invalid comment file format: "
296
                        pm_error("Invalid comment file format: "
296
                                 "first line is a continuation line! "
297
                                 "first line is a continuation line! "
297
                                 "(It starts with whitespace)");
298
                                 "(It starts with whitespace)");
298
                    continueComment(&info_ptr->text[commentIdx], 
299
                    continueComment(&text[commentIdx], 
299
                                    textline, lineLength);
300
                                    textline, lineLength);
300
                }
301
                }
301
            }
302
            }
Lines 303-314 Link Here
303
        }
304
        }
304
    } 
305
    } 
305
    if (noCommentsYet)
306
    if (noCommentsYet)
306
        info_ptr->num_text = 0;
307
        png_set_text(pngxP->png_ptr, pngxP->info_ptr, NULL, 0);
307
    else
308
    else
308
        info_ptr->num_text = commentIdx + 1;
309
        png_set_text(pngxP->png_ptr, pngxP->info_ptr, text, commentIdx + 1);
309
310
    /* TODO: does this leak memory if noCommentsYet is true? */
310
    if (verbose)
311
    if (verbose)
311
        pm_message("%d comments placed in text chunk", info_ptr->num_text);
312
        pm_message("%d comments placed in text chunk",
313
	    noCommentsYet ? 0 : commentIdx+1);
312
}
314
}
313
315
314
316
(-)netpbm-10.51.00/converter/other/pnmtopng.c.orig (-85 / +84 lines)
Lines 58-64 Link Here
58
#include <assert.h>
58
#include <assert.h>
59
#include <string.h> /* strcat() */
59
#include <string.h> /* strcat() */
60
#include <limits.h>
60
#include <limits.h>
61
#include <png.h>    /* includes zlib.h and setjmp.h */
61
#include <png.h>    /* includes setjmp.h */
62
#include <zlib.h>
62
63
63
#include "pm_c_util.h"
64
#include "pm_c_util.h"
64
#include "pnm.h"
65
#include "pnm.h"
Lines 2180-2186 Link Here
2180
            gray *               const alpha_mask,
2181
            gray *               const alpha_mask,
2181
            colorhash_table      const cht,
2182
            colorhash_table      const cht,
2182
            coloralphahash_table const caht,
2183
            coloralphahash_table const caht,
2183
            png_info *           const info_ptr,
2184
            struct pngx *        const pngxP,
2184
            xelval               const png_maxval,
2185
            xelval               const png_maxval,
2185
            unsigned int         const depth) {
2186
            unsigned int         const depth) {
2186
            
2187
            
Lines 2192-2211 Link Here
2192
        xel p_png;
2193
        xel p_png;
2193
        xel const p = xelrow[col];
2194
        xel const p = xelrow[col];
2194
        PPM_DEPTH(p_png, p, maxval, png_maxval);
2195
        PPM_DEPTH(p_png, p, maxval, png_maxval);
2195
        if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
2196
	png_byte color_type = png_get_color_type(pngxP->png_ptr,
2196
            info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
2197
			pngxP->info_ptr);
2198
        if (color_type == PNG_COLOR_TYPE_GRAY ||
2199
            color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
2197
            if (depth == 16)
2200
            if (depth == 16)
2198
                *pp++ = PNM_GET1(p_png) >> 8;
2201
                *pp++ = PNM_GET1(p_png) >> 8;
2199
            *pp++ = PNM_GET1(p_png) & 0xff;
2202
            *pp++ = PNM_GET1(p_png) & 0xff;
2200
        } else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
2203
        } else if (color_type == PNG_COLOR_TYPE_PALETTE) {
2201
            unsigned int paletteIndex;
2204
            unsigned int paletteIndex;
2202
            if (alpha)
2205
            if (alpha)
2203
                paletteIndex = lookupColorAlpha(caht, &p, &alpha_mask[col]);
2206
                paletteIndex = lookupColorAlpha(caht, &p, &alpha_mask[col]);
2204
            else
2207
            else
2205
                paletteIndex = ppm_lookupcolor(cht, &p);
2208
                paletteIndex = ppm_lookupcolor(cht, &p);
2206
            *pp++ = paletteIndex;
2209
            *pp++ = paletteIndex;
2207
        } else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
2210
        } else if (color_type == PNG_COLOR_TYPE_RGB ||
2208
                   info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
2211
                   color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
2209
            if (depth == 16)
2212
            if (depth == 16)
2210
                *pp++ = PPM_GETR(p_png) >> 8;
2213
                *pp++ = PPM_GETR(p_png) >> 8;
2211
            *pp++ = PPM_GETR(p_png) & 0xff;
2214
            *pp++ = PPM_GETR(p_png) & 0xff;
Lines 2218-2224 Link Here
2218
        } else
2221
        } else
2219
            pm_error("INTERNAL ERROR: undefined color_type");
2222
            pm_error("INTERNAL ERROR: undefined color_type");
2220
                
2223
                
2221
        if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) {
2224
        if (color_type & PNG_COLOR_MASK_ALPHA) {
2222
            int const png_alphaval = (int)
2225
            int const png_alphaval = (int)
2223
                alpha_mask[col] * (float) png_maxval / maxval + 0.5;
2226
                alpha_mask[col] * (float) png_maxval / maxval + 0.5;
2224
            if (depth == 16)
2227
            if (depth == 16)
Lines 2274-2280 Link Here
2274
            
2277
            
2275
            makePngLine(line, xelrow, cols, maxval,
2278
            makePngLine(line, xelrow, cols, maxval,
2276
                        alpha, alpha ? alpha_mask[row] : NULL,
2279
                        alpha, alpha ? alpha_mask[row] : NULL,
2277
                        cht, caht, pngxP->info_ptr, png_maxval, depth);
2280
                        cht, caht, pngxP, png_maxval, depth);
2278
2281
2279
            png_write_row(pngxP->png_ptr, line);
2282
            png_write_row(pngxP->png_ptr, line);
2280
        }
2283
        }
Lines 2293-2299 Link Here
2293
            unsigned int const rows,
2296
            unsigned int const rows,
2294
            xelval       const maxval,
2297
            xelval       const maxval,
2295
            int          const format,
2298
            int          const format,
2296
            png_info *   const info_ptr,
2299
            struct pngx* const pngxP,
2297
            bool         const verbose) {
2300
            bool         const verbose) {
2298
2301
2299
    if (histRequested) {
2302
    if (histRequested) {
Lines 2324-2331 Link Here
2324
                        histogram[i] = chv[chvIndex].value;
2327
                        histogram[i] = chv[chvIndex].value;
2325
                }
2328
                }
2326
            
2329
            
2327
                info_ptr->valid |= PNG_INFO_hIST;
2330
                png_set_hIST(pngxP->png_ptr, pngxP->info_ptr, histogram);
2328
                info_ptr->hist = histogram;
2329
                if (verbose)
2331
                if (verbose)
2330
                    pm_message("histogram created in PNG stream");
2332
                    pm_message("histogram created in PNG stream");
2331
            }
2333
            }
Lines 2336-2376 Link Here
2336
2338
2337
2339
2338
2340
2339
static void
2341
static png_byte
2340
setColorType(struct pngx * const pngxP,
2342
setColorType(struct pngx * const pngxP,
2341
             bool          const colorMapped,
2343
             bool          const colorMapped,
2342
             int           const pnmType,
2344
             int           const pnmType,
2343
             bool          const alpha) {
2345
             bool          const alpha) {
2344
2346
2347
    png_byte color_type = 0;
2348
2345
    if (colorMapped)
2349
    if (colorMapped)
2346
        pngxP->info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
2350
        color_type = PNG_COLOR_TYPE_PALETTE;
2347
    else if (pnmType == PPM_TYPE)
2351
    else if (pnmType == PPM_TYPE)
2348
        pngxP->info_ptr->color_type = PNG_COLOR_TYPE_RGB;
2352
        color_type = PNG_COLOR_TYPE_RGB;
2349
    else
2353
    else
2350
        pngxP->info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
2354
        color_type = PNG_COLOR_TYPE_GRAY;
2351
2355
2352
    if (alpha && pngxP->info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
2356
    if (alpha && color_type != PNG_COLOR_TYPE_PALETTE)
2353
        pngxP->info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
2357
        color_type |= PNG_COLOR_MASK_ALPHA;
2358
    return color_type;
2354
}
2359
}
2355
2360
2356
2361
2357
2362
2358
static void
2363
static void
2359
doGamaChunk(struct cmdlineInfo const cmdline,
2364
doGamaChunk(struct cmdlineInfo const cmdline,
2360
            png_info *         const info_ptr) {
2365
            struct pngx *      const pngxP) {
2361
            
2366
            
2362
    if (cmdline.gammaSpec) {
2367
    if (cmdline.gammaSpec) {
2363
        /* gAMA chunk */
2368
        /* gAMA chunk */
2364
        info_ptr->valid |= PNG_INFO_gAMA;
2369
        png_set_gAMA(pngxP->png_ptr, pngxP->info_ptr, cmdline.gamma);
2365
        info_ptr->gamma = cmdline.gamma;
2366
    }
2370
    }
2367
}
2371
}
2368
2372
2369
2373
2370
2374
/* TODO: needs porting */
2375
#if 0
2371
static void
2376
static void
2372
doChrmChunk(struct cmdlineInfo const cmdline,
2377
doChrmChunk(struct cmdlineInfo const cmdline,
2373
            png_info *         const info_ptr) {
2378
            struct pngx *      const pngxP) {
2374
2379
2375
    if (cmdline.rgbSpec) {
2380
    if (cmdline.rgbSpec) {
2376
        /* cHRM chunk */
2381
        /* cHRM chunk */
Lines 2386-2405 Link Here
2386
        info_ptr->y_blue  = cmdline.rgb.by;
2391
        info_ptr->y_blue  = cmdline.rgb.by;
2387
    }
2392
    }
2388
}
2393
}
2394
#endif
2389
2395
2390
2396
2391
2397
2392
static void
2398
static void
2393
doPhysChunk(struct cmdlineInfo const cmdline,
2399
doPhysChunk(struct cmdlineInfo const cmdline,
2394
            png_info *         const info_ptr) {
2400
            struct pngx *      const pngxP) {
2395
2401
2396
    if (cmdline.sizeSpec) {
2402
    if (cmdline.sizeSpec) {
2397
        /* pHYS chunk */
2403
        /* pHYS chunk */
2398
        info_ptr->valid |= PNG_INFO_pHYs;
2404
        png_set_pHYs(pngxP->png_ptr, pngxP->info_ptr,
2399
2405
                        cmdline.size.x, cmdline.size.y,
2400
        info_ptr->x_pixels_per_unit = cmdline.size.x;
2406
                        cmdline.size.unit);
2401
        info_ptr->y_pixels_per_unit = cmdline.size.y;
2402
        info_ptr->phys_unit_type    = cmdline.size.unit;
2403
    }
2407
    }
2404
}
2408
}
2405
2409
Lines 2408-2420 Link Here
2408
2412
2409
static void
2413
static void
2410
doTimeChunk(struct cmdlineInfo const cmdline,
2414
doTimeChunk(struct cmdlineInfo const cmdline,
2411
            png_info *         const info_ptr) {
2415
            struct pngx *      const pngxP) {
2412
2416
2413
    if (cmdline.modtimeSpec) {
2417
    if (cmdline.modtimeSpec) {
2414
        /* tIME chunk */
2418
        /* tIME chunk */
2415
        info_ptr->valid |= PNG_INFO_tIME;
2419
        png_timep ptime;
2416
2420
2417
        png_convert_from_time_t(&info_ptr->mod_time, cmdline.modtime);
2421
        png_convert_from_time_t(ptime, cmdline.modtime);
2422
        png_set_tIME(pngxP->png_ptr, pngxP->info_ptr, ptime);
2418
    }
2423
    }
2419
}
2424
}
2420
2425
Lines 2450-2457 Link Here
2450
            pixel         const transColor,
2455
            pixel         const transColor,
2451
            xelval        const maxval,
2456
            xelval        const maxval,
2452
            xelval        const pngMaxval) {
2457
            xelval        const pngMaxval) {
2453
2458
    png_byte color_type = png_get_color_type(pngxP->png_ptr, pngxP->info_ptr);
2454
    switch (pngxP->info_ptr->color_type) {
2459
    switch (color_type) {
2455
    case PNG_COLOR_TYPE_PALETTE:
2460
    case PNG_COLOR_TYPE_PALETTE:
2456
        if (transPaletteSize > 0) {
2461
        if (transPaletteSize > 0) {
2457
            png_set_tRNS(pngxP->png_ptr, pngxP->info_ptr,
2462
            png_set_tRNS(pngxP->png_ptr, pngxP->info_ptr,
Lines 2483-2489 Link Here
2483
2488
2484
static void
2489
static void
2485
doBkgdChunk(bool         const bkgdRequested,
2490
doBkgdChunk(bool         const bkgdRequested,
2486
            png_info *   const info_ptr,
2491
            struct pngx* const pngxP,
2487
            unsigned int const backgroundIndex,
2492
            unsigned int const backgroundIndex,
2488
            pixel        const backColor,
2493
            pixel        const backColor,
2489
            xelval       const maxval,
2494
            xelval       const maxval,
Lines 2491-2523 Link Here
2491
            bool         const verbose) {
2496
            bool         const verbose) {
2492
    
2497
    
2493
    if (bkgdRequested) {
2498
    if (bkgdRequested) {
2494
        info_ptr->valid |= PNG_INFO_bKGD;
2499
        png_color_16 bg = xelToPngColor_16(backColor, maxval, pngMaxval);
2495
        if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
2500
        png_set_bKGD(pngxP->png_ptr, pngxP->info_ptr, &bg);
2496
            info_ptr->background.index = backgroundIndex;
2501
        if (verbose)
2497
        } else {
2502
            pm_message("Writing bKGD chunk with background color "
2498
            info_ptr->background = 
2503
                       " {gray, red, green, blue} = {%d, %d, %d, %d}",
2499
                xelToPngColor_16(backColor, maxval, pngMaxval);
2504
                       bg.gray, 
2500
            if (verbose)
2505
                       bg.red, 
2501
                pm_message("Writing bKGD chunk with background color "
2506
                       bg.green, 
2502
                           " {gray, red, green, blue} = {%d, %d, %d, %d}",
2507
                       bg.blue ); 
2503
                           info_ptr->background.gray, 
2504
                           info_ptr->background.red, 
2505
                           info_ptr->background.green, 
2506
                           info_ptr->background.blue ); 
2507
        }
2508
    }
2508
    }
2509
}
2509
}
2510
2510
2511
2511
2512
2512
2513
static void
2513
static void
2514
doSbitChunk(png_info * const pngInfoP,
2514
doSbitChunk(struct pngx* const pngxP,
2515
            xelval     const pngMaxval,
2515
            xelval     const pngMaxval,
2516
            xelval     const maxval,
2516
            xelval     const maxval,
2517
            bool       const alpha,
2517
            bool       const alpha,
2518
            xelval     const alphaMaxval) {
2518
            xelval     const alphaMaxval) {
2519
2519
    png_byte color_type = png_get_color_type(pngxP->png_ptr, pngxP->info_ptr);
2520
    if (pngInfoP->color_type != PNG_COLOR_TYPE_PALETTE &&
2520
    if (color_type != PNG_COLOR_TYPE_PALETTE &&
2521
        (pngMaxval > maxval || (alpha && pngMaxval > alphaMaxval))) {
2521
        (pngMaxval > maxval || (alpha && pngMaxval > alphaMaxval))) {
2522
2522
2523
        /* We're writing in a bit depth that doesn't match the maxval
2523
        /* We're writing in a bit depth that doesn't match the maxval
Lines 2535-2562 Link Here
2535
           PNG doesn't allow it, we don't attempt to create such an
2535
           PNG doesn't allow it, we don't attempt to create such an
2536
           sBIT chunk.
2536
           sBIT chunk.
2537
        */
2537
        */
2538
2538
        png_color_8 sig_bit;
2539
        pngInfoP->valid |= PNG_INFO_sBIT;
2540
2539
2541
        {
2540
        {
2542
            int const sbitval = pm_maxvaltobits(MIN(maxval, pngMaxval));
2541
            int const sbitval = pm_maxvaltobits(MIN(maxval, pngMaxval));
2543
2542
2544
            if (pngInfoP->color_type & PNG_COLOR_MASK_COLOR) {
2543
            if (color_type & PNG_COLOR_MASK_COLOR) {
2545
                pngInfoP->sig_bit.red   = sbitval;
2544
                sig_bit.red   = sbitval;
2546
                pngInfoP->sig_bit.green = sbitval;
2545
                sig_bit.green = sbitval;
2547
                pngInfoP->sig_bit.blue  = sbitval;
2546
                sig_bit.blue  = sbitval;
2548
            } else
2547
            } else
2549
                pngInfoP->sig_bit.gray = sbitval;
2548
                sig_bit.gray = sbitval;
2550
            
2549
            
2551
            if (verbose)
2550
            if (verbose)
2552
                pm_message("Writing sBIT chunk with bits = %d", sbitval);
2551
                pm_message("Writing sBIT chunk with bits = %d", sbitval);
2553
        }
2552
        }
2554
        if (pngInfoP->color_type & PNG_COLOR_MASK_ALPHA) {
2553
        if (color_type & PNG_COLOR_MASK_ALPHA) {
2555
            pngInfoP->sig_bit.alpha =
2554
            sig_bit.alpha =
2556
                pm_maxvaltobits(MIN(alphaMaxval, pngMaxval));
2555
                pm_maxvaltobits(MIN(alphaMaxval, pngMaxval));
2557
            if (verbose)
2556
            if (verbose)
2558
                pm_message("  alpha bits = %d", pngInfoP->sig_bit.alpha);
2557
                pm_message("  alpha bits = %d", sig_bit.alpha);
2559
        }
2558
        }
2559
        png_set_sBIT(pngxP->png_ptr, pngxP->info_ptr, &sig_bit);
2560
    }
2560
    }
2561
}
2561
}
2562
2562
Lines 2755-2804 Link Here
2755
    pm_error ("setjmp returns error condition (2)");
2755
    pm_error ("setjmp returns error condition (2)");
2756
  }
2756
  }
2757
2757
2758
  pngxP->info_ptr->width = cols;
2758
  png_byte color_type = setColorType(pngxP, colorMapped, pnm_type, alpha);
2759
  pngxP->info_ptr->height = rows;
2759
  png_set_IHDR(pngxP->png_ptr, pngxP->info_ptr,
2760
  pngxP->info_ptr->bit_depth = depth;
2760
                cols, rows, depth, color_type,
2761
2761
                cmdline.interlace,
2762
  setColorType(pngxP, colorMapped, pnm_type, alpha);
2762
                PNG_COMPRESSION_TYPE_DEFAULT,
2763
2763
                PNG_FILTER_TYPE_DEFAULT);
2764
  pngxP->info_ptr->interlace_type = cmdline.interlace;
2764
2765
2765
  doGamaChunk(cmdline, pngxP);
2766
  doGamaChunk(cmdline, pngxP->info_ptr);
2766
  /* TODO: port doChrmChunk */
2767
2767
#if 0
2768
  doChrmChunk(cmdline, pngxP->info_ptr);
2768
  doChrmChunk(cmdline, pngxP);
2769
2769
#endif
2770
  doPhysChunk(cmdline, pngxP->info_ptr);
2770
  doPhysChunk(cmdline, pngxP);
2771
2771
2772
  if (pngxP->info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
2772
  if (color_type == PNG_COLOR_TYPE_PALETTE) {
2773
2773
2774
    /* creating PNG palette (Not counting the transparency palette) */
2774
    /* creating PNG palette (Not counting the transparency palette) */
2775
2775
2776
    createPngPalette(palette_pnm, palette_size, maxval,
2776
    createPngPalette(palette_pnm, palette_size, maxval,
2777
                     trans_pnm, trans_size, alpha_maxval, 
2777
                     trans_pnm, trans_size, alpha_maxval, 
2778
                     palette, trans);
2778
                     palette, trans);
2779
    pngxP->info_ptr->valid |= PNG_INFO_PLTE;
2779
    png_set_PLTE(pngxP->png_ptr, pngxP->info_ptr, palette, palette_size);
2780
    pngxP->info_ptr->palette = palette;
2781
    pngxP->info_ptr->num_palette = palette_size;
2782
2780
2783
    doHistChunk(cmdline.hist, palette_pnm, ifP, rasterPos,
2781
    doHistChunk(cmdline.hist, palette_pnm, ifP, rasterPos,
2784
                cols, rows, maxval, format,
2782
                cols, rows, maxval, format,
2785
                pngxP->info_ptr, cmdline.verbose);
2783
                pngxP, cmdline.verbose);
2786
  }
2784
  }
2787
2785
2788
  doTrnsChunk(pngxP, trans, trans_size,
2786
  doTrnsChunk(pngxP, trans, trans_size,
2789
              transparent, transcolor, maxval, png_maxval);
2787
              transparent, transcolor, maxval, png_maxval);
2790
2788
2791
  doBkgdChunk(!!cmdline.background, pngxP->info_ptr,
2789
  doBkgdChunk(!!cmdline.background, pngxP,
2792
              background_index, backcolor,
2790
              background_index, backcolor,
2793
              maxval, png_maxval, cmdline.verbose);
2791
              maxval, png_maxval, cmdline.verbose);
2794
2792
2795
  doSbitChunk(pngxP->info_ptr, png_maxval, maxval, alpha, alpha_maxval);
2793
  doSbitChunk(pngxP, png_maxval, maxval, alpha, alpha_maxval);
2796
2794
2797
  /* tEXT and zTXT chunks */
2795
  /* tEXT and zTXT chunks */
2798
  if (cmdline.text || cmdline.ztxt)
2796
  if (cmdline.text || cmdline.ztxt)
2799
      pnmpng_read_text(pngxP->info_ptr, tfP, !!cmdline.ztxt, cmdline.verbose);
2797
      pnmpng_read_text(pngxP->info_ptr, tfP, !!cmdline.ztxt, cmdline.verbose);
2800
2798
2801
  doTimeChunk(cmdline, pngxP->info_ptr);
2799
  doTimeChunk(cmdline, pngxP);
2802
2800
2803
  if (cmdline.filterSet != 0)
2801
  if (cmdline.filterSet != 0)
2804
      png_set_filter(pngxP->png_ptr, 0, cmdline.filterSet);
2802
      png_set_filter(pngxP->png_ptr, 0, cmdline.filterSet);
Lines 2809-2815 Link Here
2809
2807
2810
  /* write the png-info struct */
2808
  /* write the png-info struct */
2811
  png_write_info(pngxP->png_ptr, pngxP->info_ptr);
2809
  png_write_info(pngxP->png_ptr, pngxP->info_ptr);
2812
2810
#if 0
2811
  /* should no longer be necessary */
2813
  if (cmdline.text || cmdline.ztxt)
2812
  if (cmdline.text || cmdline.ztxt)
2814
      /* prevent from being written twice with png_write_end */
2813
      /* prevent from being written twice with png_write_end */
2815
      pngxP->info_ptr->num_text = 0;
2814
      pngxP->info_ptr->num_text = 0;
Lines 2817-2823 Link Here
2817
  if (cmdline.modtime)
2816
  if (cmdline.modtime)
2818
      /* prevent from being written twice with png_write_end */
2817
      /* prevent from being written twice with png_write_end */
2819
      pngxP->info_ptr->valid &= ~PNG_INFO_tIME;
2818
      pngxP->info_ptr->valid &= ~PNG_INFO_tIME;
2820
2819
#endif
2821
  /* let libpng take care of, e.g., bit-depth conversions */
2820
  /* let libpng take care of, e.g., bit-depth conversions */
2822
  png_set_packing(pngxP->png_ptr);
2821
  png_set_packing(pngxP->png_ptr);
2823
2822

Return to bug 355025