Lines Matching refs:color

47 -C Code for PNG (file format chunks, adam7, PNG filters, color conversions, ...)
2500 return 0; /*allowed color type / bits combination*/
2513 return 0; /*unexisting color type*/
2644 size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color)
2646 return (w * h * lodepng_get_bpp(color) + 7) / 8;
2841 lodepng_color_mode_init(&info->color);
2861 lodepng_color_mode_cleanup(&info->color);
2874 lodepng_color_mode_init(&dest->color);
2875 CERROR_TRY_RETURN(lodepng_color_mode_copy(&dest->color, &source->color));
2911 One node of a color tree
2913 index for a color. It's like an octree, but because the alpha channel is used too, each
2942 /*returns -1 if color not present, its index otherwise*/
2962 /*color is not allowed to already exist.
2981 /*put a pixel, given its RGBA color, into image of any color type*/
3016 if(index < 0) return 82; /*color not in palette*/
3055 /*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/
3099 /*Get RGBA8 color of pixel with index i (y * width + x) from the raw image with given color type.*/
3208 /*Similar to getPixelColorRGBA8, but with all the for loops inside of the color
3211 enough memory, if has_alpha is true the output is RGBA. mode has the color mode
3348 /*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with
3349 given color type, but the given color type must be 16-bit itself.*/
3389 converts from any color type to 24-bit or 32-bit (later maybe more supported). return value = LodePNG error code
3390 the out buffer must have (w * h * bpp + 7) / 8 bytes, where bpp is the bits per pixel of the output color type
3471 unsigned char key; /*a color key is required, or more*/
3570 /*a color is considered good for 8-bit if the first byte and the second byte are equal,
3592 /*only use color key if numpixels large enough to justify tRNS chunk size*/
3611 /* Color key cannot be used if an opaque pixel also has that RGB color. */
3691 /* Color key cannot be used if an opaque pixel also has that RGB color. */
3755 /*updates values of mode with a potentially smaller color model. mode_out should
3756 contain the user chosen color model, but will be overwritten with the new chosen one.*/
3981 info->color.bitdepth = in[24];
3982 info->color.colortype = (LodePNGColorType)in[25];
4004 state->error = checkColorValidity(info->color.colortype, info->color.bitdepth);
4180 for the Adam7 code, the color convert code and the output to the user.
4214 unsigned bpp = lodepng_get_bpp(&info_png->color);
4254 static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
4257 if(color->palette) lodepng_free(color->palette);
4258 color->palettesize = chunkLength / 3;
4259 color->palette = (unsigned char*)lodepng_malloc(4 * color->palettesize);
4260 if(!color->palette && color->palettesize)
4262 color->palettesize = 0;
4265 if(color->palettesize > 256) return 38; /*error: palette too big*/
4267 for(i = 0; i < color->palettesize; i++)
4269 color->palette[4 * i + 0] = data[pos++]; /*R*/
4270 color->palette[4 * i + 1] = data[pos++]; /*G*/
4271 color->palette[4 * i + 2] = data[pos++]; /*B*/
4272 color->palette[4 * i + 3] = 255; /*alpha*/
4278 static unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
4281 if(color->colortype == LCT_PALETTE)
4284 if(chunkLength > color->palettesize) return 38;
4286 for(i = 0; i < chunkLength; i++) color->palette[4 * i + 3] = data[i];
4288 else if(color->colortype == LCT_GREY)
4293 color->key_defined = 1;
4294 color->key_r = color->key_g = color->key_b = 256 * data[0] + data[1];
4296 else if(color->colortype == LCT_RGB)
4301 color->key_defined = 1;
4302 color->key_r = 256 * data[0] + data[1];
4303 color->key_g = 256 * data[2] + data[3];
4304 color->key_b = 256 * data[4] + data[5];
4306 else return 42; /*error: tRNS chunk not allowed for other color models*/
4313 /*background color chunk (bKGD)*/
4316 if(info->color.colortype == LCT_PALETTE)
4318 /*error: this chunk must be 1 byte for indexed color image*/
4324 else if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)
4333 else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)
4561 /*read a PNG, the result will be in the same color type as the PNG (hence "generic")*/
4627 state->error = readChunk_PLTE(&state->info_png.color, data, chunkLength);
4636 state->error = readChunk_tRNS(&state->info_png.color, data, chunkLength);
4640 /*background color chunk (bKGD)*/
4712 if(!ucvector_resize(&scanlines, lodepng_get_raw_size(*w, *h, &state->info_png.color) + *h))
4730 lodepng_get_raw_size(*w, *h, &state->info_png.color), 0)) state->error = 83; /*alloc fail*/
4744 if(!state->decoder.color_convert || lodepng_color_mode_equal(&state->info_raw, &state->info_png.color))
4746 /*same color type, no copying or converting of data needed*/
4747 /*store the info_png color settings on the info_raw so that the info_raw still reflects what colortype
4751 state->error = lodepng_color_mode_copy(&state->info_raw, &state->info_png.color);
4757 /*color conversion needed; sort of copy of the data*/
4762 from greyscale input color type, to 8-bit greyscale or greyscale with alpha"*/
4766 return 56; /*unsupported color mode conversion*/
4775 else state->error = lodepng_convert(*out, data, &state->info_raw, &state->info_png.color, *w, *h, state->decoder.fix_png);
4912 ucvector_push_back(&header, (unsigned char)colortype); /*color type*/
5098 if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)
5103 else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)
5112 else if(info->color.colortype == LCT_PALETTE)
5266 if(bpp == 0) return 31; /*error: invalid color type*/
5544 unsigned bpp = lodepng_get_bpp(&info_png->color);
5563 error = filter(*out, padded, w, h, &info_png->color, settings);
5570 error = filter(*out, in, w, h, &info_png->color, settings);
5603 passw[i], passh[i], &info_png->color, settings);
5609 passw[i], passh[i], &info_png->color, settings);
5625 returns 1 if the palette has a single color with alpha 0 ==> color key
5631 unsigned r = 0, g = 0, b = 0; /*the value of the color with alpha 0, so long as color keying is possible*/
5678 if((info.color.colortype == LCT_PALETTE || state->encoder.force_palette)
5679 && (info.color.palettesize == 0 || info.color.palettesize > 256))
5687 state->error = lodepng_auto_choose_color(&info.color, image, w, h, &state->info_raw,
5701 state->error = checkColorValidity(info.color.colortype, info.color.bitdepth);
5702 if(state->error) return state->error; /*error: unexisting color type given*/
5704 if(state->error) return state->error; /*error: unexisting color type given*/
5706 if(!lodepng_color_mode_equal(&state->info_raw, &info.color))
5709 size_t size = (w * h * lodepng_get_bpp(&info.color) + 7) / 8;
5715 state->error = lodepng_convert(converted, image, &info.color, &state->info_raw, w, h, 0 /*fix_png*/);
5731 addChunk_IHDR(&outv, w, h, info.color.colortype, info.color.bitdepth, info.interlace_method);
5741 if(info.color.colortype == LCT_PALETTE)
5743 addChunk_PLTE(&outv, &info.color);
5745 if(state->encoder.force_palette && (info.color.colortype == LCT_RGB || info.color.colortype == LCT_RGBA))
5747 addChunk_PLTE(&outv, &info.color);
5750 if(info.color.colortype == LCT_PALETTE && getPaletteTranslucency(info.color.palette, info.color.palettesize) != 0)
5752 addChunk_tRNS(&outv, &info.color);
5754 if((info.color.colortype == LCT_GREY || info.color.colortype == LCT_RGB) && info.color.key_defined)
5756 addChunk_tRNS(&outv, &info.color);
5863 state.info_png.color.colortype = colortype;
5864 state.info_png.color.bitdepth = bitdepth;
5945 all the pixels of the image, given the color depth and image dimensions. Something that doesn't
5957 case 31: return "illegal PNG color type or bpp";
5963 case 37: return "illegal bit depth for this color type given";
5968 case 42: return "tRNS chunk appeared while it was not allowed for this color type";
5988 case 56: return "given output image colortype or bitdepth not supported for color conversion";
5991 case 59: return "requested color conversion not supported";
5995 case 62: return "conversion from color to greyscale not supported";
6015 case 82: return "color conversion to palette requested while a color isn't in palette";
6018 case 85: return "internal color conversion bug";