Lines Matching refs:palette
279 * was done by libpng. Width and height must be less than 256. 'palette' is an
280 * index of the palette to use for formats with a palette (0 otherwise.)
282 #define FILEID(col, depth, palette, interlace, width, height, do_interlace) \
283 ((png_uint_32)((col) + ((depth)<<3) + ((palette)<<8) + ((interlace)<<13) + \
387 /* Palette images are restricted to 8 bit depth */
434 if ((colour_type & 1) == 0) /* !palette */
581 typedef struct store_palette_entry /* record of a single palette entry */
596 int npalette; /* Number of entries in palette */
597 store_palette_entry* palette; /* May be NULL */
668 store_palette_entry* palette;
744 ps->palette = NULL;
765 if (ps->palette != NULL)
767 free(ps->palette);
768 ps->palette = NULL;
800 if ((*ppf)->palette != NULL)
802 free((*ppf)->palette);
803 (*ppf)->palette = NULL;
826 pf->palette = ps->palette;
828 ps->palette = 0;
1250 store_log(ps, NULL, "attempt to write palette without write stream", 1);
1252 if (ps->palette != NULL)
1258 ps->palette = voidcast(store_palette_entry*, malloc(npalette *
1259 sizeof *ps->palette));
1261 if (ps->palette == NULL)
1262 png_error(ps->pwrite, "store new palette: OOM");
1267 return ps->palette;
1278 store_log(ps, ps->pread, "no current stream for palette", 1);
1280 /* The result may be null if there is no palette. */
1282 return ps->current->palette;
3000 * For palette image (colour type 3) multiple transform images are stored with
3003 * different code path for palette images. For size images a single palette is
3007 /* Make a 'standard' palette. Because there are only 256 entries in a palette
3008 * (maximum) this actually makes a random palette in the hope that enough tests
3009 * will catch enough errors. (Note that the same palette isn't produced every
3011 * but a given set of arguments to pngvalid will always produce the same palette
3079 store_palette_entry *palette;
3095 * a set of low bit depth palette test with any chance of a reasonable
3099 * no relationship between palette index and the color value therein!)
3101 palette = store_write_palette(ps, npalette);
3105 palette[i].alpha = values[i ^ selector[1]][0];
3106 palette[i].red = values[i ^ selector[1]][1];
3107 palette[i].green = values[i ^ selector[1]][2];
3108 palette[i].blue = values[i ^ selector[1]][3];
3111 return palette;
3115 /* Initialize a standard palette on a write stream. The 'do_tRNS' argument
3127 png_color palette[256];
3132 palette[i].red = ppal[i].red;
3133 palette[i].green = ppal[i].green;
3134 palette[i].blue = ppal[i].blue;
3139 palette[i].red = palette[i].green = palette[i].blue = 42;
3141 png_set_PLTE(pp, pi, palette, npalette);
3495 if (colour_type == 3) /* palette */
3581 * generating multiple low bit depth palette images.
3692 PNG_CONST png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
3732 if (colour_type == 3) /* palette */
3911 make_size(ps, 3, 0, 3 /*palette: max 8 bits*/);
4002 if (colour_type == 3) /* palette */
4267 int npalette; /* Number of entries in the palette. */
4269 palette;
4305 /* Preset the palette to full intensity/opaque througout: */
4306 memset(dp->palette, 0xff, sizeof dp->palette);
4309 /* Initialize the palette fields - this must be done later because the palette
4315 store_palette_entry *palette = store_current_palette(dp->ps, &dp->npalette);
4321 memcpy(dp->palette, palette, i * sizeof *palette);
4323 /* Check for a non-opaque palette entry: */
4325 if (palette[i].alpha < 255)
4340 /* Utility to read the palette from the PNG file and convert it into
4342 * palette (it does not check for a transparent colour in the non-palette case.)
4345 read_palette(store_palette palette, int *npalette, png_const_structp pp,
4364 palette[i].red = pal[i].red;
4365 palette[i].green = pal[i].green;
4366 palette[i].blue = pal[i].blue;
4372 memset(palette + *npalette, 126, (256-*npalette) * sizeof *palette);
4379 /* But there is no palette, so record this: */
4381 memset(palette, 113, sizeof (store_palette));
4388 /* Oops, if a palette tRNS gets expanded png_read_update_info (at least so
4404 png_error(pp, "validate: unexpected png_get_tRNS (palette) result");
4407 palette[i].alpha = trans_alpha[i];
4410 palette[i].alpha = 255;
4413 palette[i].alpha = 33; /* flag value */
4420 /* No palette transparency - just set the alpha channel to opaque. */
4424 palette[i].alpha = 255;
4427 palette[i].alpha = 55; /* flag value */
4433 /* Utility to validate the palette if it should not have changed (the
4441 store_palette palette;
4443 if (read_palette(palette, &npalette, pp, pi) != dp->is_transparent)
4444 png_error(pp, "validate: palette transparency changed");
4451 pos = safecat(msg, sizeof msg, pos, "validate: palette size changed: ");
4462 if (palette[i].red != dp->palette[i].red ||
4463 palette[i].green != dp->palette[i].green ||
4464 palette[i].blue != dp->palette[i].blue ||
4465 palette[i].alpha != dp->palette[i].alpha)
4545 /* All 8 bits in tRNS for a palette image are significant - see the
4569 /* Validate the colour type 3 palette (this can be present on other color
5051 /* Initialize the palette correctly from the png_store_file. */
5121 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5180 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5187 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5195 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5202 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5214 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5222 standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
5247 /* For the moment don't do the palette test - it's a waste of time when
5275 unsigned int red, green, blue, alpha; /* For non-palette images. */
5276 unsigned int palette_index; /* For a palette image. */
5327 png_byte bit_depth, png_uint_32 x, store_palette palette)
5334 * Note that this currently assumes a simple palette where entry x has colour
5344 if (colour_type == 3) /* palette */
5347 if (palette != 0)
5351 this->red = palette[i].red;
5352 this->green = palette[i].green;
5353 this->blue = palette[i].blue;
5354 this->alpha = palette[i].alpha;
5358 else /* not palette */
5387 /* Convert a palette image to an rgb image. This necessarily converts the tRNS
5388 * chunk at the same time, because the tRNS will be in palette form. The way
5389 * palette validation works means that the original palette is never updated,
5391 * corresponding palette entry and *this* is updated. Consequently this routine
5416 * least 8. Palette images will be converted to alpha (using the above API).
5822 png_error(pp, "pngvalid: internal: palette sample depth not 8");
5855 * palette images where it is always 8.) The check on 'err' is to detect
5918 /* Read the palette corresponding to the output if the output colour type
5919 * indicates a palette, othewise set out_palette to garbage.
5923 /* Validate that the palette count itself has not changed - this is not
5930 png_error(pp, "unexpected change in palette size");
5979 image_pixel_init(&in_pixel, std, in_ct, in_bd, x, dp->this.palette);
6007 png_error(pp, "unexpected transformed palette index");
6010 /* Check the colours for palette images too - in fact the palette could
6238 /* LIBPNG BUG: this always forces palette images to RGB. */
7293 bit_depth, 0/*x*/, 0/*unused: palette*/);
7594 /* png_set_quantize(png_structp, png_colorp palette, int num_palette,
8692 PNG_CONST store_palette_entry *in_palette = dp->this.palette;
8695 int out_is_transparent = 0; /* Just refers to the palette case */
8711 * the palette there is no way of finding out, because libpng fails to
8712 * update the palette on png_read_update_info. Indeed, libpng doesn't
8715 * out_ct is palette.
8738 /* Record the palette index for index images. */
8751 dp->this.palette[in_index].alpha :
8786 else /* RGB or palette */
9011 (void)gamma_test(pm, colour_type, bit_depth, 0/*palette*/, interlace_type,
9025 /* Don't test more than one instance of each palette - it's pointless, in