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

(-)converter/other/pngtxt.c.orig (-12 / +13 lines)
Lines 240-246 Link Here
240
240
241
241
242
void 
242
void 
243
pnmpng_read_text (png_info * const info_ptr, 
243
pnmpng_read_text (png_struct * png_ptr,
244
                  png_info * info_ptr, 
244
                  FILE *     const tfp, 
245
                  FILE *     const tfp, 
245
                  bool       const ztxt,
246
                  bool       const ztxt,
246
                  bool       const verbose) {
247
                  bool       const verbose) {
Lines 250-255 Link Here
250
    unsigned int commentIdx;
251
    unsigned int commentIdx;
251
    bool noCommentsYet;
252
    bool noCommentsYet;
252
    bool eof;
253
    bool eof;
254
    png_textp text_ptr;
253
    unsigned int allocatedComments;
255
    unsigned int allocatedComments;
254
        /* Number of entries currently allocated for the info_ptr->text
256
        /* Number of entries currently allocated for the info_ptr->text
255
           array 
257
           array 
Lines 257-264 Link Here
257
259
258
    allocatedComments = 256;  /* initial value */
260
    allocatedComments = 256;  /* initial value */
259
261
260
    MALLOCARRAY(info_ptr->text, allocatedComments);
262
    MALLOCARRAY(text_ptr, allocatedComments);
261
    if (info_ptr->text == NULL) 
263
    if (text_ptr == NULL) 
262
        pm_error("unable to allocate memory for comment array");
264
        pm_error("unable to allocate memory for comment array");
263
265
264
    commentIdx = 0;
266
    commentIdx = 0;
Lines 273-279 Link Here
273
            if (lineLength == 0) {
275
            if (lineLength == 0) {
274
                /* skip this empty line */
276
                /* skip this empty line */
275
            } else {
277
            } else {
276
                handleArrayAllocation(&info_ptr->text, &allocatedComments,
278
                handleArrayAllocation(&text_ptr, &allocatedComments,
277
                                      commentIdx);
279
                                      commentIdx);
278
                if ((textline[0] != ' ') && (textline[0] != '\t')) {
280
                if ((textline[0] != ' ') && (textline[0] != '\t')) {
279
                    /* Line doesn't start with white space, which
281
                    /* Line doesn't start with white space, which
Lines 285-291 Link Here
285
                        ++commentIdx;
287
                        ++commentIdx;
286
                    noCommentsYet = FALSE;
288
                    noCommentsYet = FALSE;
287
289
288
                    startComment(&info_ptr->text[commentIdx], 
290
                    startComment(&text_ptr[commentIdx], 
289
                                 textline, lineLength, ztxt);
291
                                 textline, lineLength, ztxt);
290
                } else {
292
                } else {
291
                    /* Line starts with whitespace, which means it is
293
                    /* Line starts with whitespace, which means it is
Lines 295-314 Link Here
295
                        pm_error("Invalid comment file format: "
297
                        pm_error("Invalid comment file format: "
296
                                 "first line is a continuation line! "
298
                                 "first line is a continuation line! "
297
                                 "(It starts with whitespace)");
299
                                 "(It starts with whitespace)");
298
                    continueComment(&info_ptr->text[commentIdx], 
300
                    continueComment(&text_ptr[commentIdx], 
299
                                    textline, lineLength);
301
                                    textline, lineLength);
300
                }
302
                }
301
            }
303
            }
302
            pm_strfree(textline);
304
            pm_strfree(textline);
303
        }
305
        }
304
    } 
306
    } 
305
    if (noCommentsYet)
307
    if (!noCommentsYet)
306
        info_ptr->num_text = 0;
308
        png_set_text(png_ptr, info_ptr, text_ptr, commentIdx + 1);
307
    else
308
        info_ptr->num_text = commentIdx + 1;
309
309
310
    if (verbose)
310
    if (verbose)
311
        pm_message("%d comments placed in text chunk", info_ptr->num_text);
311
        pm_message("%d comments placed in text chunk", commentIdx + 1);
312
313
    free(text_ptr);
312
}
314
}
313
315
314
316
315
-y0ulUmNC+osPPQO6
(-)converter/other/pngtxt.h.orig (-2 / +2 lines)
Lines 5-11 Link Here
5
#include <png.h>
5
#include <png.h>
6
6
7
void 
7
void 
8
pnmpng_read_text (png_info * const info_ptr, 
8
pnmpng_read_text (png_struct * png_ptr,
9
                  png_info * const info_ptr, 
9
                  FILE *     const tfp, 
10
                  FILE *     const tfp, 
10
                  bool const ztxt,
11
                  bool const ztxt,
11
                  bool const verbose);
12
                  bool const verbose);
12
-y0ulUmNC+osPPQO6
(-)converter/other/pamrgbatopng.c.orig (-5 / +2 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, pamP->width, pamP->height,
105
        infoP->height     = pamP->height;
105
                     8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0);
106
        infoP->bit_depth  = 8;
107
        infoP->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
108
        
106
        
109
        png_init_io(pngP, ofP);
107
        png_init_io(pngP, ofP);
110
108
111
-y0ulUmNC+osPPQO6
(-)converter/other/pnmtopng.c.orig (-92 / +97 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 2079-2084 Link Here
2079
            gray *               const alpha_mask,
2080
            gray *               const alpha_mask,
2080
            colorhash_table      const cht,
2081
            colorhash_table      const cht,
2081
            coloralphahash_table const caht,
2082
            coloralphahash_table const caht,
2083
            png_struct *         const png_ptr,
2082
            png_info *           const info_ptr,
2084
            png_info *           const info_ptr,
2083
            xelval               const png_maxval,
2085
            xelval               const png_maxval,
2084
            unsigned int         const depth) {
2086
            unsigned int         const depth) {
Lines 2091-2110 Link Here
2091
        xel p_png;
2093
        xel p_png;
2092
        xel const p = xelrow[col];
2094
        xel const p = xelrow[col];
2093
        PPM_DEPTH(p_png, p, maxval, png_maxval);
2095
        PPM_DEPTH(p_png, p, maxval, png_maxval);
2094
        if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
2096
        if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY ||
2095
            info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
2097
            png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA) {
2096
            if (depth == 16)
2098
            if (depth == 16)
2097
                *pp++ = PNM_GET1(p_png) >> 8;
2099
                *pp++ = PNM_GET1(p_png) >> 8;
2098
            *pp++ = PNM_GET1(p_png) & 0xff;
2100
            *pp++ = PNM_GET1(p_png) & 0xff;
2099
        } else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
2101
        } else if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
2100
            unsigned int paletteIndex;
2102
            unsigned int paletteIndex;
2101
            if (alpha)
2103
            if (alpha)
2102
                paletteIndex = lookupColorAlpha(caht, &p, &alpha_mask[col]);
2104
                paletteIndex = lookupColorAlpha(caht, &p, &alpha_mask[col]);
2103
            else
2105
            else
2104
                paletteIndex = ppm_lookupcolor(cht, &p);
2106
                paletteIndex = ppm_lookupcolor(cht, &p);
2105
            *pp++ = paletteIndex;
2107
            *pp++ = paletteIndex;
2106
        } else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
2108
        } else if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB ||
2107
                   info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
2109
                   png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA) {
2108
            if (depth == 16)
2110
            if (depth == 16)
2109
                *pp++ = PPM_GETR(p_png) >> 8;
2111
                *pp++ = PPM_GETR(p_png) >> 8;
2110
            *pp++ = PPM_GETR(p_png) & 0xff;
2112
            *pp++ = PPM_GETR(p_png) & 0xff;
Lines 2117-2123 Link Here
2117
        } else
2119
        } else
2118
            pm_error("INTERNAL ERROR: undefined color_type");
2120
            pm_error("INTERNAL ERROR: undefined color_type");
2119
                
2121
                
2120
        if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) {
2122
        if (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA) {
2121
            int const png_alphaval = (int)
2123
            int const png_alphaval = (int)
2122
                alpha_mask[col] * (float) png_maxval / maxval + 0.5;
2124
                alpha_mask[col] * (float) png_maxval / maxval + 0.5;
2123
            if (depth == 16)
2125
            if (depth == 16)
Lines 2174-2180 Link Here
2174
            
2176
            
2175
            makePngLine(line, xelrow, cols, maxval,
2177
            makePngLine(line, xelrow, cols, maxval,
2176
                        alpha, alpha ? alpha_mask[row] : NULL,
2178
                        alpha, alpha ? alpha_mask[row] : NULL,
2177
                        cht, caht, pngxP->info_ptr, png_maxval, depth);
2179
                        cht, caht, pngxP->png_ptr, pngxP->info_ptr, png_maxval, depth);
2178
2180
2179
            png_write_row(png_ptr, line);
2181
            png_write_row(png_ptr, line);
2180
        }
2182
        }
Lines 2186-2197 Link Here
2186
2188
2187
static void
2189
static void
2188
doGamaChunk(struct cmdlineInfo const cmdline,
2190
doGamaChunk(struct cmdlineInfo const cmdline,
2191
            png_struct *       const png_ptr,
2189
            png_info *         const info_ptr) {
2192
            png_info *         const info_ptr) {
2190
            
2193
            
2191
    if (cmdline.gammaSpec) {
2194
    if (cmdline.gammaSpec) {
2192
        /* gAMA chunk */
2195
        /* gAMA chunk */
2193
        info_ptr->valid |= PNG_INFO_gAMA;
2196
        png_set_gAMA(png_ptr, info_ptr, cmdline.gamma);
2194
        info_ptr->gamma = cmdline.gamma;
2195
    }
2197
    }
2196
}
2198
}
2197
2199
Lines 2199-2218 Link Here
2199
2201
2200
static void
2202
static void
2201
doChrmChunk(struct cmdlineInfo const cmdline,
2203
doChrmChunk(struct cmdlineInfo const cmdline,
2204
            png_struct *       const png_ptr,
2202
            png_info *         const info_ptr) {
2205
            png_info *         const info_ptr) {
2203
2206
2204
    if (cmdline.rgbSpec) {
2207
    if (cmdline.rgbSpec) {
2205
        /* cHRM chunk */
2208
        /* cHRM chunk */
2206
        info_ptr->valid |= PNG_INFO_cHRM;
2209
2207
2210
        png_set_cHRM (png_ptr, info_ptr, cmdline.rgb.wx, cmdline.rgb.wy,
2208
        info_ptr->x_white = cmdline.rgb.wx;
2211
                      cmdline.rgb.rx, cmdline.rgb.ry, cmdline.rgb.gx,
2209
        info_ptr->y_white = cmdline.rgb.wy;
2212
                      cmdline.rgb.gy, cmdline.rgb.bx, cmdline.rgb.by);
2210
        info_ptr->x_red   = cmdline.rgb.rx;
2211
        info_ptr->y_red   = cmdline.rgb.ry;
2212
        info_ptr->x_green = cmdline.rgb.gx;
2213
        info_ptr->y_green = cmdline.rgb.gy;
2214
        info_ptr->x_blue  = cmdline.rgb.bx;
2215
        info_ptr->y_blue  = cmdline.rgb.by;
2216
    }
2213
    }
2217
}
2214
}
2218
2215
Lines 2220-2234 Link Here
2220
2217
2221
static void
2218
static void
2222
doPhysChunk(struct cmdlineInfo const cmdline,
2219
doPhysChunk(struct cmdlineInfo const cmdline,
2220
            png_struct *       const png_ptr,
2223
            png_info *         const info_ptr) {
2221
            png_info *         const info_ptr) {
2224
2222
2225
    if (cmdline.sizeSpec) {
2223
    if (cmdline.sizeSpec) {
2226
        /* pHYS chunk */
2224
        /* pHYS chunk */
2227
        info_ptr->valid |= PNG_INFO_pHYs;
2225
        png_set_pHYs(png_ptr, info_ptr, cmdline.size.x, cmdline.size.y, cmdline.size.unit);
2228
2229
        info_ptr->x_pixels_per_unit = cmdline.size.x;
2230
        info_ptr->y_pixels_per_unit = cmdline.size.y;
2231
        info_ptr->phys_unit_type    = cmdline.size.unit;
2232
    }
2226
    }
2233
}
2227
}
2234
2228
Lines 2237-2249 Link Here
2237
2231
2238
static void
2232
static void
2239
doTimeChunk(struct cmdlineInfo const cmdline,
2233
doTimeChunk(struct cmdlineInfo const cmdline,
2234
            png_struct *       const png_ptr,
2240
            png_info *         const info_ptr) {
2235
            png_info *         const info_ptr) {
2241
2236
2242
    if (cmdline.modtimeSpec) {
2237
    if (cmdline.modtimeSpec) {
2243
        /* tIME chunk */
2238
        /* tIME chunk */
2244
        info_ptr->valid |= PNG_INFO_tIME;
2239
        png_timep ptime;
2245
2240
        png_convert_from_time_t(ptime, cmdline.modtime);
2246
        png_convert_from_time_t(&info_ptr->mod_time, cmdline.modtime);
2241
        png_set_tIME(png_ptr, info_ptr, ptime);
2247
    }
2242
    }
2248
}
2243
}
2249
2244
Lines 2260-2272 Link Here
2260
2255
2261
2256
2262
static void
2257
static void
2263
doSbitChunk(png_info * const pngInfoP,
2258
doSbitChunk(png_struct * const pngP,
2259
            png_info * const pngInfoP,
2264
            xelval     const pngMaxval,
2260
            xelval     const pngMaxval,
2265
            xelval     const maxval,
2261
            xelval     const maxval,
2266
            bool       const alpha,
2262
            bool       const alpha,
2267
            xelval     const alphaMaxval) {
2263
            xelval     const alphaMaxval) {
2268
2264
2269
    if (pngInfoP->color_type != PNG_COLOR_TYPE_PALETTE &&
2265
    if (png_get_color_type(pngP, pngInfoP) != PNG_COLOR_TYPE_PALETTE &&
2270
        (pngMaxval > maxval || (alpha && pngMaxval > alphaMaxval))) {
2266
        (pngMaxval > maxval || (alpha && pngMaxval > alphaMaxval))) {
2271
2267
2272
        /* We're writing in a bit depth that doesn't match the maxval
2268
        /* We're writing in a bit depth that doesn't match the maxval
Lines 2275-2300 Link Here
2275
           sBIT chunk.
2271
           sBIT chunk.
2276
        */
2272
        */
2277
2273
2278
        pngInfoP->valid |= PNG_INFO_sBIT;
2279
2280
        {
2274
        {
2281
            int const sbitval = pm_maxvaltobits(MIN(maxval, pngMaxval));
2275
            int const sbitval = pm_maxvaltobits(MIN(maxval, pngMaxval));
2276
            png_color_8 sbit;
2282
2277
2283
            if (pngInfoP->color_type & PNG_COLOR_MASK_COLOR) {
2278
            (void)memset(&sbit, 0, sizeof(sbit));
2284
                pngInfoP->sig_bit.red   = sbitval;
2279
            if (png_get_color_type(pngP, pngInfoP) & PNG_COLOR_MASK_COLOR) {
2285
                pngInfoP->sig_bit.green = sbitval;
2280
                sbit.red   = sbitval;
2286
                pngInfoP->sig_bit.blue  = sbitval;
2281
                sbit.green = sbitval;
2282
                sbit.blue  = sbitval;
2287
            } else
2283
            } else
2288
                pngInfoP->sig_bit.gray = sbitval;
2284
                sbit.gray = sbitval;
2289
            
2285
            
2290
            if (verbose)
2286
            if (verbose)
2291
                pm_message("Writing sBIT chunk with bits = %d", sbitval);
2287
                pm_message("Writing sBIT chunk with bits = %d", sbitval);
2292
        }
2288
2293
        if (pngInfoP->color_type & PNG_COLOR_MASK_ALPHA) {
2289
            if (png_get_color_type(pngP, pngInfoP) & PNG_COLOR_MASK_ALPHA) {
2294
            pngInfoP->sig_bit.alpha =
2290
                sbit.alpha =
2295
                pm_maxvaltobits(MIN(alphaMaxval, pngMaxval));
2291
                    pm_maxvaltobits(MIN(alphaMaxval, pngMaxval));
2296
            if (verbose)
2292
                if (verbose)
2297
                pm_message("  alpha bits = %d", pngInfoP->sig_bit.alpha);
2293
                    pm_message("  alpha bits = %d", sbit.alpha);
2294
            }
2295
            png_set_sBIT(pngP, pngInfoP, &sbit);
2298
        }
2296
        }
2299
    }
2297
    }
2300
}
2298
}
Lines 2391-2396 Link Here
2391
  xelval maxmaxval;
2382
  xelval maxmaxval;
2392
  gray ** alpha_mask;
2383
  gray ** alpha_mask;
2393
2384
2385
  int color_type;
2386
2394
  /* We initialize these guys to quiet compiler warnings: */
2387
  /* We initialize these guys to quiet compiler warnings: */
2395
  depth = 0;
2388
  depth = 0;
2396
2389
Lines 2576-2618 Link Here
2576
    pm_error ("setjmp returns error condition (2)");
2569
    pm_error ("setjmp returns error condition (2)");
2577
  }
2570
  }
2578
2571
2579
  png_init_io (png_ptr, stdout);
2580
  info_ptr->width = cols;
2581
  info_ptr->height = rows;
2582
  info_ptr->bit_depth = depth;
2583
2584
  if (colorMapped)
2572
  if (colorMapped)
2585
    info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
2573
    color_type = PNG_COLOR_TYPE_PALETTE;
2586
  else if (pnm_type == PPM_TYPE)
2574
  else if (pnm_type == PPM_TYPE) {
2587
    info_ptr->color_type = PNG_COLOR_TYPE_RGB;
2575
    if (alpha)
2588
  else
2576
      color_type = PNG_COLOR_TYPE_RGB_ALPHA;
2589
    info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
2577
    else
2578
      color_type = PNG_COLOR_TYPE_RGB;
2579
  } else {
2580
    if (alpha)
2581
      color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
2582
    else
2583
      color_type = PNG_COLOR_TYPE_GRAY;
2584
  }
2590
2585
2591
  if (alpha && info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
2586
  png_set_IHDR(png_ptr, info_ptr, cols, rows, depth, color_type, 0, 0, 0);
2592
    info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
2587
  png_init_io (png_ptr, stdout);
2593
2588
2594
  info_ptr->interlace_type = cmdline.interlace;
2589
  if (cmdline.interlace)
2590
    png_set_interlace_handling(png_ptr);
2595
2591
2596
  doGamaChunk(cmdline, info_ptr);
2592
  doGamaChunk(cmdline, png_ptr, info_ptr);
2597
2593
2598
  doChrmChunk(cmdline, info_ptr);
2594
  doChrmChunk(cmdline, png_ptr, info_ptr);
2599
2595
2600
  doPhysChunk(cmdline, info_ptr);
2596
  doPhysChunk(cmdline, png_ptr, info_ptr);
2601
2597
2602
  if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
2598
  if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
2603
2599
2604
    /* creating PNG palette  (PLTE and tRNS chunks) */
2600
    /* creating PNG palette  (PLTE and tRNS chunks) */
2605
2601
2606
    createPngPalette(palette_pnm, palette_size, maxval,
2602
    createPngPalette(palette_pnm, palette_size, maxval,
2607
                     trans_pnm, trans_size, alpha_maxval, 
2603
                     trans_pnm, trans_size, alpha_maxval, 
2608
                     palette, trans);
2604
                     palette, trans);
2609
    info_ptr->valid |= PNG_INFO_PLTE;
2605
    png_set_PLTE(png_ptr, info_ptr, palette, palette_size);
2610
    info_ptr->palette = palette;
2611
    info_ptr->num_palette = palette_size;
2612
    if (trans_size > 0) {
2606
    if (trans_size > 0) {
2613
        info_ptr->valid |= PNG_INFO_tRNS;
2607
        png_set_tRNS(png_ptr, info_ptr, trans, trans_size, NULL);
2614
        info_ptr->trans = trans;
2615
        info_ptr->num_trans = trans_size;   /* omit opaque values */
2616
    }
2608
    }
2617
    /* creating hIST chunk */
2609
    /* creating hIST chunk */
2618
    if (cmdline.hist) {
2610
    if (cmdline.hist) {
Lines 2638-2655 Link Here
2638
2630
2639
        ppm_freecolorhash(cht);
2631
        ppm_freecolorhash(cht);
2640
2632
2641
        info_ptr->valid |= PNG_INFO_hIST;
2633
        png_set_hIST(png_ptr, info_ptr, histogram);
2642
        info_ptr->hist = histogram;
2643
        if (verbose)
2634
        if (verbose)
2644
            pm_message("histogram created");
2635
            pm_message("histogram created");
2645
    }
2636
    }
2646
  } else { /* color_type != PNG_COLOR_TYPE_PALETTE */
2637
  } else { /* color_type != PNG_COLOR_TYPE_PALETTE */
2647
    if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
2638
    if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY ||
2648
        info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
2639
        png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) {
2649
        if (transparent > 0) {
2640
        if (transparent > 0) {
2650
            info_ptr->valid |= PNG_INFO_tRNS;
2641
            png_color_16 trans_color = xelToPngColor_16(transcolor, maxval, png_maxval);
2651
            info_ptr->trans_values = 
2642
            png_set_tRNS(png_ptr, info_ptr, NULL, 0, &trans_color);
2652
                xelToPngColor_16(transcolor, maxval, png_maxval);
2643
                
2653
        }
2644
        }
2654
    } else {
2645
    } else {
2655
        /* This is PNG_COLOR_MASK_ALPHA.  Transparency will be handled
2646
        /* This is PNG_COLOR_MASK_ALPHA.  Transparency will be handled
Lines 2657-2699 Link Here
2657
        */
2648
        */
2658
    }
2649
    }
2659
    if (verbose) {
2650
    if (verbose) {
2660
        if (info_ptr->valid && PNG_INFO_tRNS) 
2651
        if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
2652
            png_color_16p trans_color;
2653
2654
            png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &trans_color);
2661
            pm_message("Transparent color {gray, red, green, blue} = "
2655
            pm_message("Transparent color {gray, red, green, blue} = "
2662
                       "{%d, %d, %d, %d}",
2656
                       "{%d, %d, %d, %d}",
2663
                       info_ptr->trans_values.gray,
2657
                       trans_color->gray,
2664
                       info_ptr->trans_values.red,
2658
                       trans_color->red,
2665
                       info_ptr->trans_values.green,
2659
                       trans_color->green,
2666
                       info_ptr->trans_values.blue);
2660
                       trans_color->blue);
2667
        else
2661
        } else
2668
            pm_message("No transparent color");
2662
            pm_message("No transparent color");
2669
    }
2663
    }
2670
  }
2664
  }
2671
2665
2672
  /* bKGD chunk */
2666
  /* bKGD chunk */
2673
  if (cmdline.background) {
2667
  if (cmdline.background) {
2674
      info_ptr->valid |= PNG_INFO_bKGD;
2668
      if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
2675
      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
2669
          png_color_16 background;
2676
          info_ptr->background.index = background_index;
2670
2671
          (void)memset(&background, 0, sizeof(background));
2672
          background.index = background_index;
2673
          png_set_bKGD(png_ptr, info_ptr, &background);
2677
      } else {
2674
      } else {
2678
          info_ptr->background = 
2675
          png_color_16 background = xelToPngColor_16(backcolor, maxval, png_maxval);
2679
              xelToPngColor_16(backcolor, maxval, png_maxval);
2676
          png_set_bKGD(png_ptr, info_ptr, &background);
2680
          if (verbose)
2677
          if (verbose)
2681
              pm_message("Writing bKGD chunk with background color "
2678
              pm_message("Writing bKGD chunk with background color "
2682
                         " {gray, red, green, blue} = {%d, %d, %d, %d}",
2679
                         " {gray, red, green, blue} = {%d, %d, %d, %d}",
2683
                         info_ptr->background.gray, 
2680
                         background.gray, 
2684
                         info_ptr->background.red, 
2681
                         background.red, 
2685
                         info_ptr->background.green, 
2682
                         background.green, 
2686
                         info_ptr->background.blue ); 
2683
                         background.blue ); 
2687
      }
2684
      }
2688
  }
2685
  }
2689
2686
2690
  doSbitChunk(info_ptr, png_maxval, maxval, alpha, alpha_maxval);
2687
  doSbitChunk(png_ptr, info_ptr, png_maxval, maxval, alpha, alpha_maxval);
2691
2688
2692
  /* tEXT and zTXT chunks */
2689
  /* tEXT and zTXT chunks */
2693
  if (cmdline.text || cmdline.ztxt)
2690
  if (cmdline.text || cmdline.ztxt)
2694
      pnmpng_read_text(info_ptr, tfp, !!cmdline.ztxt, cmdline.verbose);
2691
      pnmpng_read_text(png_ptr, info_ptr, tfp, !!cmdline.ztxt, cmdline.verbose);
2695
2692
2696
  doTimeChunk(cmdline, info_ptr);
2693
  doTimeChunk(cmdline, png_ptr, info_ptr);
2697
2694
2698
  if (cmdline.filterSet != 0)
2695
  if (cmdline.filterSet != 0)
2699
      png_set_filter(png_ptr, 0, cmdline.filterSet);
2696
      png_set_filter(png_ptr, 0, cmdline.filterSet);
Lines 2703-2708 Link Here
2703
  /* write the png-info struct */
2700
  /* write the png-info struct */
2704
  png_write_info(png_ptr, info_ptr);
2701
  png_write_info(png_ptr, info_ptr);
2705
2702
2703
#if 0
2706
  if (cmdline.text || cmdline.ztxt)
2704
  if (cmdline.text || cmdline.ztxt)
2707
      /* prevent from being written twice with png_write_end */
2705
      /* prevent from being written twice with png_write_end */
2708
      info_ptr->num_text = 0;
2706
      info_ptr->num_text = 0;
Lines 2710-2715 Link Here
2710
  if (cmdline.modtime)
2708
  if (cmdline.modtime)
2711
      /* prevent from being written twice with png_write_end */
2709
      /* prevent from being written twice with png_write_end */
2712
      info_ptr->valid &= ~PNG_INFO_tIME;
2710
      info_ptr->valid &= ~PNG_INFO_tIME;
2711
#endif
2713
2712
2714
  /* let libpng take care of, e.g., bit-depth conversions */
2713
  /* let libpng take care of, e.g., bit-depth conversions */
2715
  png_set_packing (png_ptr);
2714
  png_set_packing (png_ptr);
2716
-y0ulUmNC+osPPQO6--

Return to bug 355025