Lines Matching refs:png_ptr
30 png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, variable
45 png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
49 if (png_ptr != NULL)
51 png_ptr->mode = PNG_IS_READ_STRUCT;
57 png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE;
61 png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
67 png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
75 png_set_read_fn(png_ptr, NULL, NULL);
78 return png_ptr;
92 png_read_info(png_structrp png_ptr, png_inforp info_ptr) in png_read_info() argument
100 if (png_ptr == NULL || info_ptr == NULL) in png_read_info()
104 png_read_sig(png_ptr, info_ptr); in png_read_info()
108 png_uint_32 length = png_read_chunk_header(png_ptr); in png_read_info()
109 png_uint_32 chunk_name = png_ptr->chunk_name; in png_read_info()
116 if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) in png_read_info()
117 png_chunk_error(png_ptr, "Missing IHDR before IDAT"); in png_read_info()
119 else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && in png_read_info()
120 (png_ptr->mode & PNG_HAVE_PLTE) == 0) in png_read_info()
121 png_chunk_error(png_ptr, "Missing PLTE before IDAT"); in png_read_info()
123 else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) in png_read_info()
124 png_chunk_benign_error(png_ptr, "Too many IDATs found"); in png_read_info()
126 png_ptr->mode |= PNG_HAVE_IDAT; in png_read_info()
129 else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) in png_read_info()
131 png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; in png_read_info()
132 png_ptr->mode |= PNG_AFTER_IDAT; in png_read_info()
139 png_handle_IHDR(png_ptr, info_ptr, length); in png_read_info()
142 png_handle_IEND(png_ptr, info_ptr, length); in png_read_info()
145 else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) in png_read_info()
147 png_handle_unknown(png_ptr, info_ptr, length, keep); in png_read_info()
150 png_ptr->mode |= PNG_HAVE_PLTE; in png_read_info()
154 png_ptr->idat_size = 0; /* It has been consumed */ in png_read_info()
160 png_handle_PLTE(png_ptr, info_ptr, length); in png_read_info()
164 png_ptr->idat_size = length; in png_read_info()
170 png_handle_bKGD(png_ptr, info_ptr, length); in png_read_info()
175 png_handle_cHRM(png_ptr, info_ptr, length); in png_read_info()
180 png_handle_gAMA(png_ptr, info_ptr, length); in png_read_info()
185 png_handle_hIST(png_ptr, info_ptr, length); in png_read_info()
190 png_handle_oFFs(png_ptr, info_ptr, length); in png_read_info()
195 png_handle_pCAL(png_ptr, info_ptr, length); in png_read_info()
200 png_handle_sCAL(png_ptr, info_ptr, length); in png_read_info()
205 png_handle_pHYs(png_ptr, info_ptr, length); in png_read_info()
210 png_handle_sBIT(png_ptr, info_ptr, length); in png_read_info()
215 png_handle_sRGB(png_ptr, info_ptr, length); in png_read_info()
220 png_handle_iCCP(png_ptr, info_ptr, length); in png_read_info()
225 png_handle_sPLT(png_ptr, info_ptr, length); in png_read_info()
230 png_handle_tEXt(png_ptr, info_ptr, length); in png_read_info()
235 png_handle_tIME(png_ptr, info_ptr, length); in png_read_info()
240 png_handle_tRNS(png_ptr, info_ptr, length); in png_read_info()
245 png_handle_zTXt(png_ptr, info_ptr, length); in png_read_info()
250 png_handle_iTXt(png_ptr, info_ptr, length); in png_read_info()
254 png_handle_unknown(png_ptr, info_ptr, length, in png_read_info()
262 png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) in png_read_update_info() argument
266 if (png_ptr != NULL) in png_read_update_info()
268 if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) in png_read_update_info()
270 png_read_start_row(png_ptr); in png_read_update_info()
273 png_read_transform_info(png_ptr, info_ptr); in png_read_update_info()
281 png_app_error(png_ptr, in png_read_update_info()
293 png_start_read_image(png_structrp png_ptr) in png_start_read_image() argument
297 if (png_ptr != NULL) in png_start_read_image()
299 if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) in png_start_read_image()
300 png_read_start_row(png_ptr); in png_start_read_image()
304 png_app_error(png_ptr, in png_start_read_image()
378 png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) in png_read_row() argument
382 if (png_ptr == NULL) in png_read_row()
386 (unsigned long)png_ptr->row_number, png_ptr->pass); in png_read_row()
391 if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) in png_read_row()
392 png_read_start_row(png_ptr); in png_read_row()
395 row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ in png_read_row()
396 row_info.color_type = png_ptr->color_type; in png_read_row()
397 row_info.bit_depth = png_ptr->bit_depth; in png_read_row()
398 row_info.channels = png_ptr->channels; in png_read_row()
399 row_info.pixel_depth = png_ptr->pixel_depth; in png_read_row()
403 if (png_ptr->row_number == 0 && png_ptr->pass == 0) in png_read_row()
407 if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) in png_read_row()
408 png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); in png_read_row()
412 if ((png_ptr->transformations & PNG_FILLER) != 0) in png_read_row()
413 png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); in png_read_row()
418 if ((png_ptr->transformations & PNG_PACKSWAP) != 0) in png_read_row()
419 png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); in png_read_row()
423 if ((png_ptr->transformations & PNG_PACK) != 0) in png_read_row()
424 png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); in png_read_row()
428 if ((png_ptr->transformations & PNG_SHIFT) != 0) in png_read_row()
429 png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); in png_read_row()
433 if ((png_ptr->transformations & PNG_BGR) != 0) in png_read_row()
434 png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); in png_read_row()
438 if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) in png_read_row()
439 png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); in png_read_row()
451 if (png_ptr->interlaced != 0 && in png_read_row()
452 (png_ptr->transformations & PNG_INTERLACE) != 0) in png_read_row()
454 switch (png_ptr->pass) in png_read_row()
457 if (png_ptr->row_number & 0x07) in png_read_row()
460 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
461 png_read_finish_row(png_ptr); in png_read_row()
467 if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) in png_read_row()
470 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
472 png_read_finish_row(png_ptr); in png_read_row()
478 if ((png_ptr->row_number & 0x07) != 4) in png_read_row()
480 if (dsp_row != NULL && (png_ptr->row_number & 4)) in png_read_row()
481 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
483 png_read_finish_row(png_ptr); in png_read_row()
489 if ((png_ptr->row_number & 3) || png_ptr->width < 3) in png_read_row()
492 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
494 png_read_finish_row(png_ptr); in png_read_row()
500 if ((png_ptr->row_number & 3) != 2) in png_read_row()
502 if (dsp_row != NULL && (png_ptr->row_number & 2)) in png_read_row()
503 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
505 png_read_finish_row(png_ptr); in png_read_row()
511 if ((png_ptr->row_number & 1) || png_ptr->width < 2) in png_read_row()
514 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
516 png_read_finish_row(png_ptr); in png_read_row()
523 if ((png_ptr->row_number & 1) == 0) in png_read_row()
525 png_read_finish_row(png_ptr); in png_read_row()
533 if ((png_ptr->mode & PNG_HAVE_IDAT) == 0) in png_read_row()
534 png_error(png_ptr, "Invalid attempt to read row data"); in png_read_row()
537 png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1); in png_read_row()
539 if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) in png_read_row()
541 if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) in png_read_row()
542 png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, in png_read_row()
543 png_ptr->prev_row + 1, png_ptr->row_buf[0]); in png_read_row()
545 png_error(png_ptr, "bad adaptive filter value"); in png_read_row()
553 memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); in png_read_row()
556 if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && in png_read_row()
557 (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) in png_read_row()
560 png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1); in png_read_row()
565 if (png_ptr->transformations) in png_read_row()
566 png_do_read_transformations(png_ptr, &row_info); in png_read_row()
570 if (png_ptr->transformed_pixel_depth == 0) in png_read_row()
572 png_ptr->transformed_pixel_depth = row_info.pixel_depth; in png_read_row()
573 if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) in png_read_row()
574 png_error(png_ptr, "sequential row overflow"); in png_read_row()
577 else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) in png_read_row()
578 png_error(png_ptr, "internal sequential row size calculation error"); in png_read_row()
582 if (png_ptr->interlaced != 0 && in png_read_row()
583 (png_ptr->transformations & PNG_INTERLACE) != 0) in png_read_row()
585 if (png_ptr->pass < 6) in png_read_row()
586 png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, in png_read_row()
587 png_ptr->transformations); in png_read_row()
590 png_combine_row(png_ptr, dsp_row, 1/*display*/); in png_read_row()
593 png_combine_row(png_ptr, row, 0/*row*/); in png_read_row()
600 png_combine_row(png_ptr, row, -1/*ignored*/); in png_read_row()
603 png_combine_row(png_ptr, dsp_row, -1/*ignored*/); in png_read_row()
605 png_read_finish_row(png_ptr); in png_read_row()
607 if (png_ptr->read_row_fn != NULL) in png_read_row()
608 (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); in png_read_row()
639 png_read_rows(png_structrp png_ptr, png_bytepp row, in png_read_rows() argument
648 if (png_ptr == NULL) in png_read_rows()
659 png_read_row(png_ptr, rptr, dptr); in png_read_rows()
666 png_read_row(png_ptr, rptr, NULL); in png_read_rows()
674 png_read_row(png_ptr, NULL, dptr); in png_read_rows()
694 png_read_image(png_structrp png_ptr, png_bytepp image) in png_read_image() argument
702 if (png_ptr == NULL) in png_read_image()
706 if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) in png_read_image()
708 pass = png_set_interlace_handling(png_ptr); in png_read_image()
710 png_start_read_image(png_ptr); in png_read_image()
714 if (png_ptr->interlaced != 0 && in png_read_image()
715 (png_ptr->transformations & PNG_INTERLACE) == 0) in png_read_image()
721 png_warning(png_ptr, "Interlace handling should be turned on when " in png_read_image()
724 png_ptr->num_rows = png_ptr->height; in png_read_image()
730 pass = png_set_interlace_handling(png_ptr); in png_read_image()
733 if (png_ptr->interlaced) in png_read_image()
734 png_error(png_ptr, in png_read_image()
740 image_height=png_ptr->height; in png_read_image()
747 png_read_row(png_ptr, *rp, NULL); in png_read_image()
760 png_read_end(png_structrp png_ptr, png_inforp info_ptr) in png_read_end() argument
768 if (png_ptr == NULL) in png_read_end()
775 if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0) in png_read_end()
777 png_read_finish_IDAT(png_ptr); in png_read_end()
781 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && in png_read_end()
782 png_ptr->num_palette_max > png_ptr->num_palette) in png_read_end()
783 png_benign_error(png_ptr, "Read palette index exceeding num_palette"); in png_read_end()
788 png_uint_32 length = png_read_chunk_header(png_ptr); in png_read_end()
789 png_uint_32 chunk_name = png_ptr->chunk_name; in png_read_end()
792 png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; in png_read_end()
795 png_handle_IEND(png_ptr, info_ptr, length); in png_read_end()
798 png_handle_IHDR(png_ptr, info_ptr, length); in png_read_end()
801 png_crc_finish(png_ptr, length); in png_read_end()
804 else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) in png_read_end()
808 if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) in png_read_end()
809 || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) in png_read_end()
810 png_benign_error(png_ptr, ".Too many IDATs found"); in png_read_end()
812 png_handle_unknown(png_ptr, info_ptr, length, keep); in png_read_end()
814 png_ptr->mode |= PNG_HAVE_PLTE; in png_read_end()
826 if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) in png_read_end()
827 || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) in png_read_end()
828 png_benign_error(png_ptr, "..Too many IDATs found"); in png_read_end()
830 png_crc_finish(png_ptr, length); in png_read_end()
833 png_handle_PLTE(png_ptr, info_ptr, length); in png_read_end()
837 png_handle_bKGD(png_ptr, info_ptr, length); in png_read_end()
842 png_handle_cHRM(png_ptr, info_ptr, length); in png_read_end()
847 png_handle_gAMA(png_ptr, info_ptr, length); in png_read_end()
852 png_handle_hIST(png_ptr, info_ptr, length); in png_read_end()
857 png_handle_oFFs(png_ptr, info_ptr, length); in png_read_end()
862 png_handle_pCAL(png_ptr, info_ptr, length); in png_read_end()
867 png_handle_sCAL(png_ptr, info_ptr, length); in png_read_end()
872 png_handle_pHYs(png_ptr, info_ptr, length); in png_read_end()
877 png_handle_sBIT(png_ptr, info_ptr, length); in png_read_end()
882 png_handle_sRGB(png_ptr, info_ptr, length); in png_read_end()
887 png_handle_iCCP(png_ptr, info_ptr, length); in png_read_end()
892 png_handle_sPLT(png_ptr, info_ptr, length); in png_read_end()
897 png_handle_tEXt(png_ptr, info_ptr, length); in png_read_end()
902 png_handle_tIME(png_ptr, info_ptr, length); in png_read_end()
907 png_handle_tRNS(png_ptr, info_ptr, length); in png_read_end()
912 png_handle_zTXt(png_ptr, info_ptr, length); in png_read_end()
917 png_handle_iTXt(png_ptr, info_ptr, length); in png_read_end()
921 png_handle_unknown(png_ptr, info_ptr, length, in png_read_end()
923 } while ((png_ptr->mode & PNG_HAVE_IEND) == 0); in png_read_end()
929 png_read_destroy(png_structrp png_ptr) in png_read_destroy() argument
934 png_destroy_gamma_table(png_ptr); in png_read_destroy()
937 png_free(png_ptr, png_ptr->big_row_buf); in png_read_destroy()
938 png_ptr->big_row_buf = NULL; in png_read_destroy()
939 png_free(png_ptr, png_ptr->big_prev_row); in png_read_destroy()
940 png_ptr->big_prev_row = NULL; in png_read_destroy()
941 png_free(png_ptr, png_ptr->read_buffer); in png_read_destroy()
942 png_ptr->read_buffer = NULL; in png_read_destroy()
945 png_free(png_ptr, png_ptr->palette_lookup); in png_read_destroy()
946 png_ptr->palette_lookup = NULL; in png_read_destroy()
947 png_free(png_ptr, png_ptr->quantize_index); in png_read_destroy()
948 png_ptr->quantize_index = NULL; in png_read_destroy()
951 if ((png_ptr->free_me & PNG_FREE_PLTE) != 0) in png_read_destroy()
953 png_zfree(png_ptr, png_ptr->palette); in png_read_destroy()
954 png_ptr->palette = NULL; in png_read_destroy()
956 png_ptr->free_me &= ~PNG_FREE_PLTE; in png_read_destroy()
960 if ((png_ptr->free_me & PNG_FREE_TRNS) != 0) in png_read_destroy()
962 png_free(png_ptr, png_ptr->trans_alpha); in png_read_destroy()
963 png_ptr->trans_alpha = NULL; in png_read_destroy()
965 png_ptr->free_me &= ~PNG_FREE_TRNS; in png_read_destroy()
968 inflateEnd(&png_ptr->zstream); in png_read_destroy()
971 png_free(png_ptr, png_ptr->save_buffer); in png_read_destroy()
972 png_ptr->save_buffer = NULL; in png_read_destroy()
977 png_free(png_ptr, png_ptr->unknown_chunk.data); in png_read_destroy()
978 png_ptr->unknown_chunk.data = NULL; in png_read_destroy()
982 png_free(png_ptr, png_ptr->chunk_list); in png_read_destroy()
983 png_ptr->chunk_list = NULL; in png_read_destroy()
997 png_structrp png_ptr = NULL; in png_destroy_read_struct() local
1002 png_ptr = *png_ptr_ptr; in png_destroy_read_struct()
1004 if (png_ptr == NULL) in png_destroy_read_struct()
1011 png_destroy_info_struct(png_ptr, end_info_ptr_ptr); in png_destroy_read_struct()
1012 png_destroy_info_struct(png_ptr, info_ptr_ptr); in png_destroy_read_struct()
1015 png_read_destroy(png_ptr); in png_destroy_read_struct()
1016 png_destroy_png_struct(png_ptr); in png_destroy_read_struct()
1020 png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) in png_set_read_status_fn() argument
1022 if (png_ptr == NULL) in png_set_read_status_fn()
1025 png_ptr->read_row_fn = read_row_fn; in png_set_read_status_fn()
1032 png_read_png(png_structrp png_ptr, png_inforp info_ptr, in png_read_png() argument
1036 if (png_ptr == NULL || info_ptr == NULL) in png_read_png()
1042 png_read_info(png_ptr, info_ptr); in png_read_png()
1044 png_error(png_ptr, "Image is too high to process with png_read_png()"); in png_read_png()
1060 png_set_scale_16(png_ptr); in png_read_png()
1062 png_app_error(png_ptr, "PNG_TRANSFORM_SCALE_16 not supported"); in png_read_png()
1071 png_set_strip_16(png_ptr); in png_read_png()
1073 png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_16 not supported"); in png_read_png()
1081 png_set_strip_alpha(png_ptr); in png_read_png()
1083 png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_ALPHA not supported"); in png_read_png()
1091 png_set_packing(png_ptr); in png_read_png()
1093 png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported"); in png_read_png()
1101 png_set_packswap(png_ptr); in png_read_png()
1103 png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported"); in png_read_png()
1113 png_set_expand(png_ptr); in png_read_png()
1115 png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported"); in png_read_png()
1125 png_set_invert_mono(png_ptr); in png_read_png()
1127 png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported"); in png_read_png()
1137 png_set_shift(png_ptr, &info_ptr->sig_bit); in png_read_png()
1139 png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported"); in png_read_png()
1145 png_set_bgr(png_ptr); in png_read_png()
1147 png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported"); in png_read_png()
1153 png_set_swap_alpha(png_ptr); in png_read_png()
1155 png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported"); in png_read_png()
1161 png_set_swap(png_ptr); in png_read_png()
1163 png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported"); in png_read_png()
1170 png_set_invert_alpha(png_ptr); in png_read_png()
1172 png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported"); in png_read_png()
1179 png_set_gray_to_rgb(png_ptr); in png_read_png()
1181 png_app_error(png_ptr, "PNG_TRANSFORM_GRAY_TO_RGB not supported"); in png_read_png()
1187 png_set_expand_16(png_ptr); in png_read_png()
1189 png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND_16 not supported"); in png_read_png()
1197 (void)png_set_interlace_handling(png_ptr); in png_read_png()
1203 png_read_update_info(png_ptr, info_ptr); in png_read_png()
1207 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); in png_read_png()
1212 info_ptr->row_pointers = png_voidcast(png_bytepp, png_malloc(png_ptr, in png_read_png()
1222 png_malloc(png_ptr, info_ptr->rowbytes)); in png_read_png()
1225 png_read_image(png_ptr, info_ptr->row_pointers); in png_read_png()
1229 png_read_end(png_ptr, info_ptr); in png_read_png()
1294 png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image, in png_image_read_init() local
1303 if (png_ptr != NULL) in png_image_read_init()
1305 png_infop info_ptr = png_create_info_struct(png_ptr); in png_image_read_init()
1310 png_malloc_warn(png_ptr, (sizeof *control))); in png_image_read_init()
1316 control->png_ptr = png_ptr; in png_image_read_init()
1325 png_destroy_info_struct(png_ptr, &info_ptr); in png_image_read_init()
1328 png_destroy_read_struct(&png_ptr, NULL, NULL); in png_image_read_init()
1339 png_image_format(png_structrp png_ptr) in png_image_format() argument
1343 if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) in png_image_format()
1346 if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) in png_image_format()
1354 else if (png_ptr->num_trans > 0) in png_image_format()
1357 if (png_ptr->bit_depth == 16) in png_image_format()
1360 if ((png_ptr->color_type & PNG_COLOR_MASK_PALETTE) != 0) in png_image_format()
1394 png_structrp png_ptr = image->opaque->png_ptr; in png_image_read_header() local
1397 png_set_benign_errors(png_ptr, 1/*warn*/); in png_image_read_header()
1398 png_read_info(png_ptr, info_ptr); in png_image_read_header()
1401 image->width = png_ptr->width; in png_image_read_header()
1402 image->height = png_ptr->height; in png_image_read_header()
1405 png_uint_32 format = png_image_format(png_ptr); in png_image_read_header()
1415 if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags in png_image_read_header()
1428 switch (png_ptr->color_type) in png_image_read_header()
1431 cmap_entries = 1U << png_ptr->bit_depth; in png_image_read_header()
1435 cmap_entries = png_ptr->num_palette; in png_image_read_header()
1466 image->opaque->png_ptr->io_ptr = file; in png_image_begin_read_from_stdio()
1496 image->opaque->png_ptr->io_ptr = fp; in png_image_begin_read_from_file()
1523 png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) in png_image_memory_read() argument
1525 if (png_ptr != NULL) in png_image_memory_read()
1527 png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr); in png_image_memory_read()
1544 png_error(png_ptr, "read beyond end of data"); in png_image_memory_read()
1548 png_error(png_ptr, "invalid memory read"); in png_image_memory_read()
1567 image->opaque->png_ptr->io_ptr = image; in png_image_begin_read_from_memory()
1568 image->opaque->png_ptr->read_data_fn = png_image_memory_read; in png_image_begin_read_from_memory()
1591 png_image_skip_unused_chunks(png_structrp png_ptr) in png_image_skip_unused_chunks() argument
1626 png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, in png_image_skip_unused_chunks()
1630 png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, in png_image_skip_unused_chunks()
1650 png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma; in set_file_encoding()
1698 png_error(display->image->opaque->png_ptr, in decode_gamma()
1755 png_error(image->opaque->png_ptr, "color-map index out of range"); in png_create_colormap_entry()
1855 png_error(image->opaque->png_ptr, "bad encoding (internal error)"); in png_create_colormap_entry()
2076 const png_structrp png_ptr = image->opaque->png_ptr; in png_image_read_colormap() local
2099 if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 || in png_image_read_colormap()
2100 png_ptr->num_trans > 0) /* alpha in input */ && in png_image_read_colormap()
2107 png_error(png_ptr, in png_image_read_colormap()
2138 if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0) in png_image_read_colormap()
2145 if (png_ptr->bit_depth == 16 && in png_image_read_colormap()
2147 png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR; in png_image_read_colormap()
2150 png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE; in png_image_read_colormap()
2152 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; in png_image_read_colormap()
2160 switch (png_ptr->color_type) in png_image_read_colormap()
2163 if (png_ptr->bit_depth <= 8) in png_image_read_colormap()
2170 cmap_entries = 1U << png_ptr->bit_depth; in png_image_read_colormap()
2172 png_error(png_ptr, "gray[8] color-map: too few entries"); in png_image_read_colormap()
2180 if (png_ptr->num_trans > 0) in png_image_read_colormap()
2182 trans = png_ptr->trans_color.gray; in png_image_read_colormap()
2226 if (png_ptr->bit_depth < 8) in png_image_read_colormap()
2227 png_set_packing(png_ptr); in png_image_read_colormap()
2251 png_error(png_ptr, "gray[16] color-map: too few entries"); in png_image_read_colormap()
2255 if (png_ptr->num_trans > 0) in png_image_read_colormap()
2293 png_set_background_fixed(png_ptr, &c, in png_image_read_colormap()
2349 png_error(png_ptr, "gray+alpha color-map: too few entries"); in png_image_read_colormap()
2383 png_error(png_ptr, "gray-alpha color-map: too few entries"); in png_image_read_colormap()
2402 png_set_background_fixed(png_ptr, &c, in png_image_read_colormap()
2417 png_error(png_ptr, "ga-alpha color-map: too few entries"); in png_image_read_colormap()
2504 png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, in png_image_read_colormap()
2511 if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || in png_image_read_colormap()
2512 png_ptr->num_trans > 0) && in png_image_read_colormap()
2522 png_error(png_ptr, "rgb[ga] color-map: too few entries"); in png_image_read_colormap()
2536 png_error(png_ptr, "rgb[gray] color-map: too few entries"); in png_image_read_colormap()
2546 if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || in png_image_read_colormap()
2547 png_ptr->num_trans > 0) && in png_image_read_colormap()
2548 png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0) in png_image_read_colormap()
2559 if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || in png_image_read_colormap()
2560 png_ptr->num_trans > 0) in png_image_read_colormap()
2581 png_ptr->colorspace.gamma)); /* now P_FILE */ in png_image_read_colormap()
2611 png_set_background_fixed(png_ptr, &c, in png_image_read_colormap()
2630 if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || in png_image_read_colormap()
2631 png_ptr->num_trans > 0) in png_image_read_colormap()
2641 png_error(png_ptr, "rgb+alpha color-map: too few entries"); in png_image_read_colormap()
2690 png_error(png_ptr, "rgb-alpha color-map: too few entries"); in png_image_read_colormap()
2760 png_set_background_fixed(png_ptr, &c, in png_image_read_colormap()
2775 png_error(png_ptr, "rgb color-map: too few entries"); in png_image_read_colormap()
2788 unsigned int num_trans = png_ptr->num_trans; in png_image_read_colormap()
2789 png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL; in png_image_read_colormap()
2790 png_const_colorp colormap = png_ptr->palette; in png_image_read_colormap()
2801 cmap_entries = png_ptr->num_palette; in png_image_read_colormap()
2806 png_error(png_ptr, "palette color-map: too few entries"); in png_image_read_colormap()
2843 if (png_ptr->bit_depth < 8) in png_image_read_colormap()
2844 png_set_packing(png_ptr); in png_image_read_colormap()
2849 png_error(png_ptr, "invalid PNG color type"); in png_image_read_colormap()
2854 if (expand_tRNS != 0 && png_ptr->num_trans > 0 && in png_image_read_colormap()
2855 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0) in png_image_read_colormap()
2856 png_set_tRNS_to_alpha(png_ptr); in png_image_read_colormap()
2862 png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); in png_image_read_colormap()
2866 if (png_ptr->bit_depth > 8) in png_image_read_colormap()
2867 png_set_scale_16(png_ptr); in png_image_read_colormap()
2872 png_error(png_ptr, "bad data option (internal error)"); in png_image_read_colormap()
2877 png_error(png_ptr, "color map overflow (BAD internal error)"); in png_image_read_colormap()
2911 png_error(png_ptr, "bad processing option (internal error)"); in png_image_read_colormap()
2914 png_error(png_ptr, "bad background index (internal error)"); in png_image_read_colormap()
2929 png_structrp png_ptr = image->opaque->png_ptr; in png_image_read_and_map() local
2936 switch (png_ptr->interlaced) in png_image_read_and_map()
2947 png_error(png_ptr, "unknown interlace type"); in png_image_read_and_map()
2963 if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) in png_image_read_and_map()
2989 png_read_row(png_ptr, inrow, NULL); in png_image_read_and_map()
3119 png_structrp png_ptr = control->png_ptr; in png_image_read_colormapped() local
3124 PNG_SKIP_CHUNKS(png_ptr); in png_image_read_colormapped()
3131 passes = png_set_interlace_handling(png_ptr); in png_image_read_colormapped()
3133 png_read_update_info(png_ptr, info_ptr); in png_image_read_colormapped()
3157 png_ptr->screen_gamma == PNG_GAMMA_sRGB && in png_image_read_colormapped()
3167 png_ptr->screen_gamma == PNG_GAMMA_sRGB && in png_image_read_colormapped()
3177 png_ptr->screen_gamma == PNG_GAMMA_sRGB && in png_image_read_colormapped()
3186 png_error(png_ptr, "bad color-map processing (internal error)"); in png_image_read_colormapped()
3214 png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); in png_image_read_colormapped()
3219 png_free(png_ptr, row); in png_image_read_colormapped()
3235 png_read_row(png_ptr, row, NULL); in png_image_read_colormapped()
3251 png_structrp png_ptr = image->opaque->png_ptr; in png_image_read_composite() local
3254 switch (png_ptr->interlaced) in png_image_read_composite()
3265 png_error(png_ptr, "unknown interlace type"); in png_image_read_composite()
3281 if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) in png_image_read_composite()
3308 png_read_row(png_ptr, inrow, NULL); in png_image_read_composite()
3378 png_structrp png_ptr = image->opaque->png_ptr; in png_image_read_background() local
3389 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) in png_image_read_background()
3390 png_error(png_ptr, "lost rgb to gray"); in png_image_read_background()
3392 if ((png_ptr->transformations & PNG_COMPOSE) != 0) in png_image_read_background()
3393 png_error(png_ptr, "unexpected compose"); in png_image_read_background()
3395 if (png_get_channels(png_ptr, info_ptr) != 2) in png_image_read_background()
3396 png_error(png_ptr, "lost/gained channels"); in png_image_read_background()
3401 png_error(png_ptr, "unexpected 8-bit transformation"); in png_image_read_background()
3403 switch (png_ptr->interlaced) in png_image_read_background()
3414 png_error(png_ptr, "unknown interlace type"); in png_image_read_background()
3441 if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) in png_image_read_background()
3470 png_read_row(png_ptr, inrow, NULL); in png_image_read_background()
3515 png_read_row(png_ptr, inrow, NULL); in png_image_read_background()
3579 if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) in png_image_read_background()
3606 png_read_row(png_ptr, png_voidcast(png_bytep, in png_image_read_background()
3644 png_error(png_ptr, "unexpected bit depth"); in png_image_read_background()
3658 png_structrp png_ptr = image->opaque->png_ptr; in png_image_read_direct() local
3671 png_set_expand(png_ptr); in png_image_read_direct()
3675 png_uint_32 base_format = png_image_format(png_ptr) & in png_image_read_direct()
3686 png_set_gray_to_rgb(png_ptr); in png_image_read_direct()
3706 png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, in png_image_read_direct()
3727 png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default); in png_image_read_direct()
3765 if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, in png_image_read_direct()
3782 png_set_expand_16(png_ptr); in png_image_read_direct()
3785 png_set_scale_16(png_ptr); in png_image_read_direct()
3809 png_set_strip_alpha(png_ptr); in png_image_read_direct()
3828 png_set_background_fixed(png_ptr, &c, in png_image_read_direct()
3872 png_set_add_alpha(png_ptr, filler, where); in png_image_read_direct()
3883 png_set_alpha_mode_fixed(png_ptr, mode, output_gamma); in png_image_read_direct()
3892 png_set_bgr(png_ptr); in png_image_read_direct()
3915 png_set_swap_alpha(png_ptr); in png_image_read_direct()
3933 png_set_swap(png_ptr); in png_image_read_direct()
3938 png_error(png_ptr, "png_read_image: unsupported transformation"); in png_image_read_direct()
3941 PNG_SKIP_CHUNKS(png_ptr); in png_image_read_direct()
3950 passes = png_set_interlace_handling(png_ptr); in png_image_read_direct()
3952 png_read_update_info(png_ptr, info_ptr); in png_image_read_direct()
3973 png_error(png_ptr, "png_image_read: alpha channel lost"); in png_image_read_direct()
3979 if ((png_ptr->transformations & PNG_BGR) != 0) in png_image_read_direct()
3990 if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 || in png_image_read_direct()
3991 ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 && in png_image_read_direct()
3992 (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0)) in png_image_read_direct()
3995 png_error(png_ptr, "unexpected alpha swap transformation"); in png_image_read_direct()
4003 png_error(png_ptr, "png_read_image: invalid transformations"); in png_image_read_direct()
4035 png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); in png_image_read_direct()
4040 png_free(png_ptr, row); in png_image_read_direct()
4048 png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); in png_image_read_direct()
4053 png_free(png_ptr, row); in png_image_read_direct()
4069 png_read_row(png_ptr, row, NULL); in png_image_read_direct()