Lines Matching refs:info

2670 void lodepng_color_mode_init(LodePNGColorMode* info) {  in lodepng_color_mode_init()  argument
2671 info->key_defined = 0; in lodepng_color_mode_init()
2672 info->key_r = info->key_g = info->key_b = 0; in lodepng_color_mode_init()
2673 info->colortype = LCT_RGBA; in lodepng_color_mode_init()
2674 info->bitdepth = 8; in lodepng_color_mode_init()
2675 info->palette = 0; in lodepng_color_mode_init()
2676 info->palettesize = 0; in lodepng_color_mode_init()
2680 static void lodepng_color_mode_alloc_palette(LodePNGColorMode* info) { in lodepng_color_mode_alloc_palette() argument
2684 if(!info->palette) info->palette = (unsigned char*)lodepng_malloc(1024); in lodepng_color_mode_alloc_palette()
2685 if(!info->palette) return; /*alloc fail*/ in lodepng_color_mode_alloc_palette()
2690 info->palette[i * 4 + 0] = 0; in lodepng_color_mode_alloc_palette()
2691 info->palette[i * 4 + 1] = 0; in lodepng_color_mode_alloc_palette()
2692 info->palette[i * 4 + 2] = 0; in lodepng_color_mode_alloc_palette()
2693 info->palette[i * 4 + 3] = 255; in lodepng_color_mode_alloc_palette()
2697 void lodepng_color_mode_cleanup(LodePNGColorMode* info) { in lodepng_color_mode_cleanup() argument
2698 lodepng_palette_clear(info); in lodepng_color_mode_cleanup()
2737 void lodepng_palette_clear(LodePNGColorMode* info) { in lodepng_palette_clear() argument
2738 if(info->palette) lodepng_free(info->palette); in lodepng_palette_clear()
2739 info->palette = 0; in lodepng_palette_clear()
2740 info->palettesize = 0; in lodepng_palette_clear()
2743 unsigned lodepng_palette_add(LodePNGColorMode* info, in lodepng_palette_add() argument
2745 if(!info->palette) /*allocate palette if empty*/ { in lodepng_palette_add()
2746 lodepng_color_mode_alloc_palette(info); in lodepng_palette_add()
2747 if(!info->palette) return 83; /*alloc fail*/ in lodepng_palette_add()
2749 if(info->palettesize >= 256) { in lodepng_palette_add()
2752 info->palette[4 * info->palettesize + 0] = r; in lodepng_palette_add()
2753 info->palette[4 * info->palettesize + 1] = g; in lodepng_palette_add()
2754 info->palette[4 * info->palettesize + 2] = b; in lodepng_palette_add()
2755 info->palette[4 * info->palettesize + 3] = a; in lodepng_palette_add()
2756 ++info->palettesize; in lodepng_palette_add()
2761 unsigned lodepng_get_bpp(const LodePNGColorMode* info) { in lodepng_get_bpp() argument
2762 return lodepng_get_bpp_lct(info->colortype, info->bitdepth); in lodepng_get_bpp()
2765 unsigned lodepng_get_channels(const LodePNGColorMode* info) { in lodepng_get_channels() argument
2766 return getNumColorChannels(info->colortype); in lodepng_get_channels()
2769 unsigned lodepng_is_greyscale_type(const LodePNGColorMode* info) { in lodepng_is_greyscale_type() argument
2770 return info->colortype == LCT_GREY || info->colortype == LCT_GREY_ALPHA; in lodepng_is_greyscale_type()
2773 unsigned lodepng_is_alpha_type(const LodePNGColorMode* info) { in lodepng_is_alpha_type() argument
2774 return (info->colortype & 4) != 0; /*4 or 6*/ in lodepng_is_alpha_type()
2777 unsigned lodepng_is_palette_type(const LodePNGColorMode* info) { in lodepng_is_palette_type() argument
2778 return info->colortype == LCT_PALETTE; in lodepng_is_palette_type()
2781 unsigned lodepng_has_palette_alpha(const LodePNGColorMode* info) { in lodepng_has_palette_alpha() argument
2783 for(i = 0; i != info->palettesize; ++i) { in lodepng_has_palette_alpha()
2784 if(info->palette[i * 4 + 3] < 255) return 1; in lodepng_has_palette_alpha()
2789 unsigned lodepng_can_have_alpha(const LodePNGColorMode* info) { in lodepng_can_have_alpha() argument
2790 return info->key_defined in lodepng_can_have_alpha()
2791 || lodepng_is_alpha_type(info) in lodepng_can_have_alpha()
2792 || lodepng_has_palette_alpha(info); in lodepng_can_have_alpha()
2850 static void LodePNGUnknownChunks_init(LodePNGInfo* info) { in LodePNGUnknownChunks_init() argument
2852 for(i = 0; i != 3; ++i) info->unknown_chunks_data[i] = 0; in LodePNGUnknownChunks_init()
2853 for(i = 0; i != 3; ++i) info->unknown_chunks_size[i] = 0; in LodePNGUnknownChunks_init()
2856 static void LodePNGUnknownChunks_cleanup(LodePNGInfo* info) { in LodePNGUnknownChunks_cleanup() argument
2858 for(i = 0; i != 3; ++i) lodepng_free(info->unknown_chunks_data[i]); in LodePNGUnknownChunks_cleanup()
2881 static void LodePNGText_init(LodePNGInfo* info) { in LodePNGText_init() argument
2882 info->text_num = 0; in LodePNGText_init()
2883 info->text_keys = NULL; in LodePNGText_init()
2884 info->text_strings = NULL; in LodePNGText_init()
2887 static void LodePNGText_cleanup(LodePNGInfo* info) { in LodePNGText_cleanup() argument
2889 for(i = 0; i != info->text_num; ++i) { in LodePNGText_cleanup()
2890 string_cleanup(&info->text_keys[i]); in LodePNGText_cleanup()
2891 string_cleanup(&info->text_strings[i]); in LodePNGText_cleanup()
2893 lodepng_free(info->text_keys); in LodePNGText_cleanup()
2894 lodepng_free(info->text_strings); in LodePNGText_cleanup()
2908 static unsigned lodepng_add_text_sized(LodePNGInfo* info, const char* key, const char* str, size_t … in lodepng_add_text_sized() argument
2909 …char** new_keys = (char**)(lodepng_realloc(info->text_keys, sizeof(char*) * (info->text_num + 1))); in lodepng_add_text_sized()
2910 …char** new_strings = (char**)(lodepng_realloc(info->text_strings, sizeof(char*) * (info->text_num … in lodepng_add_text_sized()
2912 if(new_keys) info->text_keys = new_keys; in lodepng_add_text_sized()
2913 if(new_strings) info->text_strings = new_strings; in lodepng_add_text_sized()
2917 ++info->text_num; in lodepng_add_text_sized()
2918 info->text_keys[info->text_num - 1] = alloc_string(key); in lodepng_add_text_sized()
2919 info->text_strings[info->text_num - 1] = alloc_string_sized(str, size); in lodepng_add_text_sized()
2920 …if(!info->text_keys[info->text_num - 1] || !info->text_strings[info->text_num - 1]) return 83; /*a… in lodepng_add_text_sized()
2925 unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str) { in lodepng_add_text() argument
2926 return lodepng_add_text_sized(info, key, str, lodepng_strlen(str)); in lodepng_add_text()
2929 void lodepng_clear_text(LodePNGInfo* info) { in lodepng_clear_text() argument
2930 LodePNGText_cleanup(info); in lodepng_clear_text()
2935 static void LodePNGIText_init(LodePNGInfo* info) { in LodePNGIText_init() argument
2936 info->itext_num = 0; in LodePNGIText_init()
2937 info->itext_keys = NULL; in LodePNGIText_init()
2938 info->itext_langtags = NULL; in LodePNGIText_init()
2939 info->itext_transkeys = NULL; in LodePNGIText_init()
2940 info->itext_strings = NULL; in LodePNGIText_init()
2943 static void LodePNGIText_cleanup(LodePNGInfo* info) { in LodePNGIText_cleanup() argument
2945 for(i = 0; i != info->itext_num; ++i) { in LodePNGIText_cleanup()
2946 string_cleanup(&info->itext_keys[i]); in LodePNGIText_cleanup()
2947 string_cleanup(&info->itext_langtags[i]); in LodePNGIText_cleanup()
2948 string_cleanup(&info->itext_transkeys[i]); in LodePNGIText_cleanup()
2949 string_cleanup(&info->itext_strings[i]); in LodePNGIText_cleanup()
2951 lodepng_free(info->itext_keys); in LodePNGIText_cleanup()
2952 lodepng_free(info->itext_langtags); in LodePNGIText_cleanup()
2953 lodepng_free(info->itext_transkeys); in LodePNGIText_cleanup()
2954 lodepng_free(info->itext_strings); in LodePNGIText_cleanup()
2971 void lodepng_clear_itext(LodePNGInfo* info) { in lodepng_clear_itext() argument
2972 LodePNGIText_cleanup(info); in lodepng_clear_itext()
2975 static unsigned lodepng_add_itext_sized(LodePNGInfo* info, const char* key, const char* langtag, in lodepng_add_itext_sized() argument
2977 …char** new_keys = (char**)(lodepng_realloc(info->itext_keys, sizeof(char*) * (info->itext_num + 1)… in lodepng_add_itext_sized()
2978 …char** new_langtags = (char**)(lodepng_realloc(info->itext_langtags, sizeof(char*) * (info->itext_… in lodepng_add_itext_sized()
2979 …char** new_transkeys = (char**)(lodepng_realloc(info->itext_transkeys, sizeof(char*) * (info->itex… in lodepng_add_itext_sized()
2980 …char** new_strings = (char**)(lodepng_realloc(info->itext_strings, sizeof(char*) * (info->itext_nu… in lodepng_add_itext_sized()
2982 if(new_keys) info->itext_keys = new_keys; in lodepng_add_itext_sized()
2983 if(new_langtags) info->itext_langtags = new_langtags; in lodepng_add_itext_sized()
2984 if(new_transkeys) info->itext_transkeys = new_transkeys; in lodepng_add_itext_sized()
2985 if(new_strings) info->itext_strings = new_strings; in lodepng_add_itext_sized()
2989 ++info->itext_num; in lodepng_add_itext_sized()
2991 info->itext_keys[info->itext_num - 1] = alloc_string(key); in lodepng_add_itext_sized()
2992 info->itext_langtags[info->itext_num - 1] = alloc_string(langtag); in lodepng_add_itext_sized()
2993 info->itext_transkeys[info->itext_num - 1] = alloc_string(transkey); in lodepng_add_itext_sized()
2994 info->itext_strings[info->itext_num - 1] = alloc_string_sized(str, size); in lodepng_add_itext_sized()
2999 unsigned lodepng_add_itext(LodePNGInfo* info, const char* key, const char* langtag, in lodepng_add_itext() argument
3001 return lodepng_add_itext_sized(info, key, langtag, transkey, str, lodepng_strlen(str)); in lodepng_add_itext()
3005 static unsigned lodepng_assign_icc(LodePNGInfo* info, const char* name, const unsigned char* profil… in lodepng_assign_icc() argument
3008 info->iccp_name = alloc_string(name); in lodepng_assign_icc()
3009 info->iccp_profile = (unsigned char*)lodepng_malloc(profile_size); in lodepng_assign_icc()
3011 if(!info->iccp_name || !info->iccp_profile) return 83; /*alloc fail*/ in lodepng_assign_icc()
3013 lodepng_memcpy(info->iccp_profile, profile, profile_size); in lodepng_assign_icc()
3014 info->iccp_profile_size = profile_size; in lodepng_assign_icc()
3019 unsigned lodepng_set_icc(LodePNGInfo* info, const char* name, const unsigned char* profile, unsigne… in lodepng_set_icc() argument
3020 if(info->iccp_name) lodepng_clear_icc(info); in lodepng_set_icc()
3021 info->iccp_defined = 1; in lodepng_set_icc()
3023 return lodepng_assign_icc(info, name, profile, profile_size); in lodepng_set_icc()
3026 void lodepng_clear_icc(LodePNGInfo* info) { in lodepng_clear_icc() argument
3027 string_cleanup(&info->iccp_name); in lodepng_clear_icc()
3028 lodepng_free(info->iccp_profile); in lodepng_clear_icc()
3029 info->iccp_profile = NULL; in lodepng_clear_icc()
3030 info->iccp_profile_size = 0; in lodepng_clear_icc()
3031 info->iccp_defined = 0; in lodepng_clear_icc()
3035 void lodepng_info_init(LodePNGInfo* info) { in lodepng_info_init() argument
3036 lodepng_color_mode_init(&info->color); in lodepng_info_init()
3037 info->interlace_method = 0; in lodepng_info_init()
3038 info->compression_method = 0; in lodepng_info_init()
3039 info->filter_method = 0; in lodepng_info_init()
3041 info->background_defined = 0; in lodepng_info_init()
3042 info->background_r = info->background_g = info->background_b = 0; in lodepng_info_init()
3044 LodePNGText_init(info); in lodepng_info_init()
3045 LodePNGIText_init(info); in lodepng_info_init()
3047 info->time_defined = 0; in lodepng_info_init()
3048 info->phys_defined = 0; in lodepng_info_init()
3050 info->gama_defined = 0; in lodepng_info_init()
3051 info->chrm_defined = 0; in lodepng_info_init()
3052 info->srgb_defined = 0; in lodepng_info_init()
3053 info->iccp_defined = 0; in lodepng_info_init()
3054 info->iccp_name = NULL; in lodepng_info_init()
3055 info->iccp_profile = NULL; in lodepng_info_init()
3057 LodePNGUnknownChunks_init(info); in lodepng_info_init()
3061 void lodepng_info_cleanup(LodePNGInfo* info) { in lodepng_info_cleanup() argument
3062 lodepng_color_mode_cleanup(&info->color); in lodepng_info_cleanup()
3064 LodePNGText_cleanup(info); in lodepng_info_cleanup()
3065 LodePNGIText_cleanup(info); in lodepng_info_cleanup()
3067 lodepng_clear_icc(info); in lodepng_info_cleanup()
3069 LodePNGUnknownChunks_cleanup(info); in lodepng_info_cleanup()
4043 LodePNGInfo* info = &state->info_png; in lodepng_inspect() local
4053 lodepng_info_cleanup(info); in lodepng_inspect()
4054 lodepng_info_init(info); in lodepng_inspect()
4073 info->color.bitdepth = in[24]; in lodepng_inspect()
4074 info->color.colortype = (LodePNGColorType)in[25]; in lodepng_inspect()
4075 info->compression_method = in[26]; in lodepng_inspect()
4076 info->filter_method = in[27]; in lodepng_inspect()
4077 info->interlace_method = in[28]; in lodepng_inspect()
4084 state->error = checkColorValidity(info->color.colortype, info->color.bitdepth); in lodepng_inspect()
4087 if(info->compression_method != 0) CERROR_RETURN_ERROR(state->error, 32); in lodepng_inspect()
4089 if(info->filter_method != 0) CERROR_RETURN_ERROR(state->error, 33); in lodepng_inspect()
4091 if(info->interlace_method > 1) CERROR_RETURN_ERROR(state->error, 34); in lodepng_inspect()
4402 static unsigned readChunk_bKGD(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_bKGD() argument
4403 if(info->color.colortype == LCT_PALETTE) { in readChunk_bKGD()
4408 if(data[0] >= info->color.palettesize) return 103; in readChunk_bKGD()
4410 info->background_defined = 1; in readChunk_bKGD()
4411 info->background_r = info->background_g = info->background_b = data[0]; in readChunk_bKGD()
4412 } else if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA) { in readChunk_bKGD()
4417 info->background_defined = 1; in readChunk_bKGD()
4418 info->background_r = info->background_g = info->background_b = 256u * data[0] + data[1]; in readChunk_bKGD()
4419 } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA) { in readChunk_bKGD()
4424 info->background_defined = 1; in readChunk_bKGD()
4425 info->background_r = 256u * data[0] + data[1]; in readChunk_bKGD()
4426 info->background_g = 256u * data[2] + data[3]; in readChunk_bKGD()
4427 info->background_b = 256u * data[4] + data[5]; in readChunk_bKGD()
4434 static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_tEXt() argument
4462 error = lodepng_add_text(info, key, str); in readChunk_tEXt()
4474 static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecoderSettings* decoder, in readChunk_zTXt() argument
4510 error = lodepng_add_text_sized(info, key, (char*)str, size); in readChunk_zTXt()
4521 static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecoderSettings* decoder, in readChunk_iTXt() argument
4591 if(!error) error = lodepng_add_itext_sized(info, key, langtag, transkey, (char*)str, size); in readChunk_iTXt()
4594 error = lodepng_add_itext_sized(info, key, langtag, transkey, (char*)(data + begin), length); in readChunk_iTXt()
4607 static unsigned readChunk_tIME(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_tIME() argument
4610 info->time_defined = 1; in readChunk_tIME()
4611 info->time.year = 256u * data[0] + data[1]; in readChunk_tIME()
4612 info->time.month = data[2]; in readChunk_tIME()
4613 info->time.day = data[3]; in readChunk_tIME()
4614 info->time.hour = data[4]; in readChunk_tIME()
4615 info->time.minute = data[5]; in readChunk_tIME()
4616 info->time.second = data[6]; in readChunk_tIME()
4621 static unsigned readChunk_pHYs(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_pHYs() argument
4624 info->phys_defined = 1; in readChunk_pHYs()
4625 info->phys_x = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3]; in readChunk_pHYs()
4626 info->phys_y = 16777216u * data[4] + 65536u * data[5] + 256u * data[6] + data[7]; in readChunk_pHYs()
4627 info->phys_unit = data[8]; in readChunk_pHYs()
4632 static unsigned readChunk_gAMA(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_gAMA() argument
4635 info->gama_defined = 1; in readChunk_gAMA()
4636 info->gama_gamma = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3]; in readChunk_gAMA()
4641 static unsigned readChunk_cHRM(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_cHRM() argument
4644 info->chrm_defined = 1; in readChunk_cHRM()
4645 info->chrm_white_x = 16777216u * data[ 0] + 65536u * data[ 1] + 256u * data[ 2] + data[ 3]; in readChunk_cHRM()
4646 info->chrm_white_y = 16777216u * data[ 4] + 65536u * data[ 5] + 256u * data[ 6] + data[ 7]; in readChunk_cHRM()
4647 info->chrm_red_x = 16777216u * data[ 8] + 65536u * data[ 9] + 256u * data[10] + data[11]; in readChunk_cHRM()
4648 info->chrm_red_y = 16777216u * data[12] + 65536u * data[13] + 256u * data[14] + data[15]; in readChunk_cHRM()
4649 info->chrm_green_x = 16777216u * data[16] + 65536u * data[17] + 256u * data[18] + data[19]; in readChunk_cHRM()
4650 info->chrm_green_y = 16777216u * data[20] + 65536u * data[21] + 256u * data[22] + data[23]; in readChunk_cHRM()
4651 info->chrm_blue_x = 16777216u * data[24] + 65536u * data[25] + 256u * data[26] + data[27]; in readChunk_cHRM()
4652 info->chrm_blue_y = 16777216u * data[28] + 65536u * data[29] + 256u * data[30] + data[31]; in readChunk_cHRM()
4657 static unsigned readChunk_sRGB(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) { in readChunk_sRGB() argument
4660 info->srgb_defined = 1; in readChunk_sRGB()
4661 info->srgb_intent = data[0]; in readChunk_sRGB()
4666 static unsigned readChunk_iCCP(LodePNGInfo* info, const LodePNGDecoderSettings* decoder, in readChunk_iCCP() argument
4676 info->iccp_defined = 1; in readChunk_iCCP()
4677 if(info->iccp_name) lodepng_clear_icc(info); in readChunk_iCCP()
4683 info->iccp_name = (char*)lodepng_malloc(length + 1); in readChunk_iCCP()
4684 if(!info->iccp_name) return 83; /*alloc fail*/ in readChunk_iCCP()
4686 info->iccp_name[length] = 0; in readChunk_iCCP()
4687 for(i = 0; i != length; ++i) info->iccp_name[i] = (char)data[i]; in readChunk_iCCP()
4696 error = zlib_decompress(&info->iccp_profile, &size, 0, in readChunk_iCCP()
4701 info->iccp_profile_size = size; in readChunk_iCCP()
4702 if(!error && !info->iccp_profile_size) error = 100; /*invalid ICC profile size*/ in readChunk_iCCP()
5121 static unsigned addChunk_PLTE(ucvector* out, const LodePNGColorMode* info) { in addChunk_PLTE() argument
5125 CERROR_TRY_RETURN(lodepng_chunk_init(&chunk, out, info->palettesize * 3, "PLTE")); in addChunk_PLTE()
5127 for(i = 0; i != info->palettesize; ++i) { in addChunk_PLTE()
5129 chunk[j++] = info->palette[i * 4 + 0]; in addChunk_PLTE()
5130 chunk[j++] = info->palette[i * 4 + 1]; in addChunk_PLTE()
5131 chunk[j++] = info->palette[i * 4 + 2]; in addChunk_PLTE()
5138 static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info) { in addChunk_tRNS() argument
5141 if(info->colortype == LCT_PALETTE) { in addChunk_tRNS()
5142 size_t i, amount = info->palettesize; in addChunk_tRNS()
5144 for(i = info->palettesize; i != 0; --i) { in addChunk_tRNS()
5145 if(info->palette[4 * (i - 1) + 3] != 255) break; in addChunk_tRNS()
5151 for(i = 0; i != amount; ++i) chunk[8 + i] = info->palette[4 * i + 3]; in addChunk_tRNS()
5153 } else if(info->colortype == LCT_GREY) { in addChunk_tRNS()
5154 if(info->key_defined) { in addChunk_tRNS()
5156 chunk[8] = (unsigned char)(info->key_r >> 8); in addChunk_tRNS()
5157 chunk[9] = (unsigned char)(info->key_r & 255); in addChunk_tRNS()
5159 } else if(info->colortype == LCT_RGB) { in addChunk_tRNS()
5160 if(info->key_defined) { in addChunk_tRNS()
5162 chunk[8] = (unsigned char)(info->key_r >> 8); in addChunk_tRNS()
5163 chunk[9] = (unsigned char)(info->key_r & 255); in addChunk_tRNS()
5164 chunk[10] = (unsigned char)(info->key_g >> 8); in addChunk_tRNS()
5165 chunk[11] = (unsigned char)(info->key_g & 255); in addChunk_tRNS()
5166 chunk[12] = (unsigned char)(info->key_b >> 8); in addChunk_tRNS()
5167 chunk[13] = (unsigned char)(info->key_b & 255); in addChunk_tRNS()
5280 static unsigned addChunk_bKGD(ucvector* out, const LodePNGInfo* info) { in addChunk_bKGD() argument
5282 if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA) { in addChunk_bKGD()
5284 chunk[8] = (unsigned char)(info->background_r >> 8); in addChunk_bKGD()
5285 chunk[9] = (unsigned char)(info->background_r & 255); in addChunk_bKGD()
5286 } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA) { in addChunk_bKGD()
5288 chunk[8] = (unsigned char)(info->background_r >> 8); in addChunk_bKGD()
5289 chunk[9] = (unsigned char)(info->background_r & 255); in addChunk_bKGD()
5290 chunk[10] = (unsigned char)(info->background_g >> 8); in addChunk_bKGD()
5291 chunk[11] = (unsigned char)(info->background_g & 255); in addChunk_bKGD()
5292 chunk[12] = (unsigned char)(info->background_b >> 8); in addChunk_bKGD()
5293 chunk[13] = (unsigned char)(info->background_b & 255); in addChunk_bKGD()
5294 } else if(info->color.colortype == LCT_PALETTE) { in addChunk_bKGD()
5296 chunk[8] = (unsigned char)(info->background_r & 255); /*palette index*/ in addChunk_bKGD()
5316 static unsigned addChunk_pHYs(ucvector* out, const LodePNGInfo* info) { in addChunk_pHYs() argument
5319 lodepng_set32bitInt(chunk + 8, info->phys_x); in addChunk_pHYs()
5320 lodepng_set32bitInt(chunk + 12, info->phys_y); in addChunk_pHYs()
5321 chunk[16] = info->phys_unit; in addChunk_pHYs()
5326 static unsigned addChunk_gAMA(ucvector* out, const LodePNGInfo* info) { in addChunk_gAMA() argument
5329 lodepng_set32bitInt(chunk + 8, info->gama_gamma); in addChunk_gAMA()
5334 static unsigned addChunk_cHRM(ucvector* out, const LodePNGInfo* info) { in addChunk_cHRM() argument
5337 lodepng_set32bitInt(chunk + 8, info->chrm_white_x); in addChunk_cHRM()
5338 lodepng_set32bitInt(chunk + 12, info->chrm_white_y); in addChunk_cHRM()
5339 lodepng_set32bitInt(chunk + 16, info->chrm_red_x); in addChunk_cHRM()
5340 lodepng_set32bitInt(chunk + 20, info->chrm_red_y); in addChunk_cHRM()
5341 lodepng_set32bitInt(chunk + 24, info->chrm_green_x); in addChunk_cHRM()
5342 lodepng_set32bitInt(chunk + 28, info->chrm_green_y); in addChunk_cHRM()
5343 lodepng_set32bitInt(chunk + 32, info->chrm_blue_x); in addChunk_cHRM()
5344 lodepng_set32bitInt(chunk + 36, info->chrm_blue_y); in addChunk_cHRM()
5349 static unsigned addChunk_sRGB(ucvector* out, const LodePNGInfo* info) { in addChunk_sRGB() argument
5350 unsigned char data = info->srgb_intent; in addChunk_sRGB()
5354 static unsigned addChunk_iCCP(ucvector* out, const LodePNGInfo* info, LodePNGCompressSettings* zlib… in addChunk_iCCP() argument
5359 size_t keysize = lodepng_strlen(info->iccp_name); in addChunk_iCCP()
5363 info->iccp_profile, info->iccp_profile_size, zlibsettings); in addChunk_iCCP()
5369 lodepng_memcpy(chunk + 8, info->iccp_name, keysize); in addChunk_iCCP()
5823 LodePNGInfo info; in lodepng_encode() local
5826 lodepng_info_init(&info); in lodepng_encode()
5853 lodepng_info_copy(&info, &state->info_png); in lodepng_encode()
5882 state->error = auto_choose_color(&info.color, &state->info_raw, &stats); in lodepng_encode()
5887 if(lodepng_convert_rgb(&info.background_r, &info.background_g, &info.background_b, in lodepng_encode()
5888 …info_png->background_r, info_png->background_g, info_png->background_b, &info.color, &info_png->co… in lodepng_encode()
5899 unsigned gray_png = info.color.colortype == LCT_GREY || info.color.colortype == LCT_GREY_ALPHA; in lodepng_encode()
5912 if(!lodepng_color_mode_equal(&state->info_raw, &info.color)) { in lodepng_encode()
5914 size_t size = ((size_t)w * (size_t)h * (size_t)lodepng_get_bpp(&info.color) + 7u) / 8u; in lodepng_encode()
5919 state->error = lodepng_convert(converted, image, &info.color, &state->info_raw, w, h); in lodepng_encode()
5922 state->error = preProcessScanlines(&data, &datasize, converted, w, h, &info, &state->encoder); in lodepng_encode()
5927 state->error = preProcessScanlines(&data, &datasize, image, w, h, &info, &state->encoder); in lodepng_encode()
5939 …state->error = addChunk_IHDR(&outv, w, h, info.color.colortype, info.color.bitdepth, info.interlac… in lodepng_encode()
5943 if(info.unknown_chunks_data[0]) { in lodepng_encode()
5944 … state->error = addUnknownChunks(&outv, info.unknown_chunks_data[0], info.unknown_chunks_size[0]); in lodepng_encode()
5948 if(info.iccp_defined) { in lodepng_encode()
5949 state->error = addChunk_iCCP(&outv, &info, &state->encoder.zlibsettings); in lodepng_encode()
5952 if(info.srgb_defined) { in lodepng_encode()
5953 state->error = addChunk_sRGB(&outv, &info); in lodepng_encode()
5956 if(info.gama_defined) { in lodepng_encode()
5957 state->error = addChunk_gAMA(&outv, &info); in lodepng_encode()
5960 if(info.chrm_defined) { in lodepng_encode()
5961 state->error = addChunk_cHRM(&outv, &info); in lodepng_encode()
5966 if(info.color.colortype == LCT_PALETTE) { in lodepng_encode()
5967 state->error = addChunk_PLTE(&outv, &info.color); in lodepng_encode()
5970 …if(state->encoder.force_palette && (info.color.colortype == LCT_RGB || info.color.colortype == LCT… in lodepng_encode()
5972 state->error = addChunk_PLTE(&outv, &info.color); in lodepng_encode()
5976 state->error = addChunk_tRNS(&outv, &info.color); in lodepng_encode()
5980 if(info.background_defined) { in lodepng_encode()
5981 state->error = addChunk_bKGD(&outv, &info); in lodepng_encode()
5985 if(info.phys_defined) { in lodepng_encode()
5986 state->error = addChunk_pHYs(&outv, &info); in lodepng_encode()
5991 if(info.unknown_chunks_data[1]) { in lodepng_encode()
5992 … state->error = addUnknownChunks(&outv, info.unknown_chunks_data[1], info.unknown_chunks_size[1]); in lodepng_encode()
6001 if(info.time_defined) { in lodepng_encode()
6002 state->error = addChunk_tIME(&outv, &info.time); in lodepng_encode()
6006 for(i = 0; i != info.text_num; ++i) { in lodepng_encode()
6007 if(lodepng_strlen(info.text_keys[i]) > 79) { in lodepng_encode()
6011 if(lodepng_strlen(info.text_keys[i]) < 1) { in lodepng_encode()
6016 …state->error = addChunk_zTXt(&outv, info.text_keys[i], info.text_strings[i], &state->encoder.zlibs… in lodepng_encode()
6019 state->error = addChunk_tEXt(&outv, info.text_keys[i], info.text_strings[i]); in lodepng_encode()
6026 for(i = 0; i != info.text_num; ++i) { in lodepng_encode()
6027 const char* k = info.text_keys[i]; in lodepng_encode()
6041 for(i = 0; i != info.itext_num; ++i) { in lodepng_encode()
6042 if(lodepng_strlen(info.itext_keys[i]) > 79) { in lodepng_encode()
6046 if(lodepng_strlen(info.itext_keys[i]) < 1) { in lodepng_encode()
6052info.itext_keys[i], info.itext_langtags[i], info.itext_transkeys[i], info.itext_strings[i], in lodepng_encode()
6058 if(info.unknown_chunks_data[2]) { in lodepng_encode()
6059 … state->error = addUnknownChunks(&outv, info.unknown_chunks_data[2], info.unknown_chunks_size[2]); in lodepng_encode()
6068 lodepng_info_cleanup(&info); in lodepng_encode()