34 # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) 57 #define PNG_BYTES_TO_CHECK 4 58 int check_if_png(
char *file_name, FILE **
fp)
60 char buf[PNG_BYTES_TO_CHECK];
63 if ((*fp = fopen(file_name,
"rb")) == NULL)
67 if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
83 void read_png(
char *file_name)
87 unsigned int sig_read = 0;
92 if ((fp = fopen(file_name,
"rb")) == NULL)
95 void read_png(FILE *fp,
unsigned int sig_read)
110 png_voidp user_error_ptr, user_error_fn, user_warning_fn);
120 if (info_ptr == NULL)
175 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
240 else if ((gamma_str =
getenv(
"SCREEN_GAMMA")) != NULL)
283 png_color std_color_cube[MAX_SCREEN_COLORS];
289 else if (
png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
296 max_screen_colors, histogram, 0);
316 if (color_type & PNG_COLOR_MASK_COLOR)
358 for (pass = 0; pass < number_passes; pass++)
367 for (
y = 0;
y <
height;
y += number_of_rows)
412 png_voidp user_error_ptr, user_error_fn, user_warning_fn);
414 if (*png_ptr == NULL)
422 if (*info_ptr == NULL)
447 info_callback, row_callback, end_callback);
508 if ((row_num >= 0) && (row_num < height))
518 if ((old_row != NULL) && (new_row != NULL))
559 void write_png(
char *file_name )
567 fp = fopen(file_name,
"wb");
578 png_voidp user_error_ptr, user_error_fn, user_warning_fn);
588 if (info_ptr == NULL)
614 user_IO_flush_function);
635 png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
651 sig_bit.red = true_red_bit_depth;
652 sig_bit.green = true_green_bit_depth;
653 sig_bit.blue = true_blue_bit_depth;
655 sig_bit.alpha = true_alpha_bit_depth;
669 text_ptr[1].text =
"Leonardo DaVinci";
674 #ifdef PNG_iTXt_SUPPORTED 752 png_error (png_ptr,
"Image is too tall to process in memory");
754 for (k = 0; k <
height; k++)
755 row_pointers[k] = image + k*width*bytes_per_pixel;
767 for (pass = 0; pass < number_passes; pass++)
770 png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
void PNGAPI png_set_packing(png_structp png_ptr)
void PNGAPI png_set_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
void PNGAPI png_write_image(png_structp png_ptr, png_bytepp image)
void PNGAPI png_write_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params)
png_bytep png_bytep new_row
png_uint_32 PNGAPI png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
#define PNG_FILLER_BEFORE
void PNGAPI png_process_data(png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)
png_infop PNGAPI png_create_info_struct(png_structp png_ptr)
png_infop png_textp * text_ptr
png_colorp int num_palette
#define PNG_BACKGROUND_GAMMA_SCREEN
#define PNG_MAX_PALETTE_LENGTH
void PNGAPI png_set_palette_to_rgb(png_structp png_ptr)
png_uint_32 PNGAPI png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
void PNGAPI png_write_rows(png_structp png_ptr, png_bytepp row, png_uint_32 num_rows)
#define PNG_COLOR_TYPE_PALETTE
png_colorp int int png_uint_16p histogram
void PNGAPI png_set_dither(png_structp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither)
png_uint_32 PNGAPI png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
void PNGAPI png_set_background(png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)
void PNGAPI png_read_rows(png_structp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)
#define PNG_LIBPNG_VER_STRING
void PNGAPI png_progressive_combine_row(png_structp png_ptr, png_bytep old_row, png_bytep new_row)
void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes)
void PNGAPI png_set_strip_16(png_structp png_ptr)
void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
png_bytep png_bytep png_size_t length
#define PNG_BACKGROUND_GAMMA_FILE
void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
png_infop png_bytep * trans
void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit)
png_infop png_uint_32 * width
void PNGAPI png_set_gray_1_2_4_to_8(png_structp png_ptr)
void PNGAPI png_set_bgr(png_structp png_ptr)
#define PNG_TEXT_COMPRESSION_zTXt
#define png_uint_16p_NULL
png_infop png_bytepp row_pointers
png_uint_32 PNGAPI png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
#define PNG_TEXT_COMPRESSION_NONE
png_struct FAR * png_structp
void PNGAPI png_write_info(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
#define PNG_COLOR_MASK_COLOR
png_uint_32 PNGAPI png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette)
void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message)
void PNGAPI png_set_packswap(png_structp png_ptr)
png_infop png_uint_32 png_uint_32 * height
png_uint_32 PNGAPI png_get_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_type, int *compression_type, int *filter_type)
void PNGAPI png_set_swap(png_structp png_ptr)
#define PNG_COLOR_TYPE_GRAY
png_uint_16 FAR * png_uint_16p
void PNGAPI png_write_end(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp palette, int num_palette)
void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
int PNGAPI png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
void PNGAPI png_set_strip_alpha(png_structp png_ptr)
#define png_jmpbuf(png_ptr)
void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
void PNGAPI png_set_invert_mono(png_structp png_ptr)
png_infop png_uint_32 png_uint_32 int * bit_depth
char * getenv(const char *name)
#define PNG_FILTER_TYPE_BASE
png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
#define PNG_COMPRESSION_TYPE_BASE
png_infop png_uint_32 png_uint_32 int int * color_type
png_uint_32 PNGAPI png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background)
void PNGAPI png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_infop png_bytep buffer
png_color_8 FAR * png_color_8p
int PNGAPI png_set_interlace_handling(png_structp png_ptr)
void PNGAPI png_set_tRNS_to_alpha(png_structp png_ptr)
void PNGAPI png_read_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params)
void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits)
void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image)
png_structp PNGAPI png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
void PNGAPI png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text)
void PNGAPI png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)
unsigned long png_uint_32
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
png_uint_32 PNGAPI png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_swap_alpha(png_structp png_ptr)
void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr)
png_uint_32 PNGAPI png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp)
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
png_infop png_color_8p * sig_bit
png_color FAR * png_colorp