Lines Matching refs:image

550    png_image   image;  member
568 newimage(Image *image) in newimage() argument
570 memset(image, 0, sizeof *image); in newimage()
576 resetimage(Image *image) in resetimage() argument
578 if (image->input_file != NULL) in resetimage()
579 rewind(image->input_file); in resetimage()
586 freebuffer(Image *image) in freebuffer() argument
588 if (image->buffer) free(image->buffer); in freebuffer()
589 image->buffer = NULL; in freebuffer()
590 image->bufsize = 0; in freebuffer()
591 image->allocsize = 0; in freebuffer()
598 freeimage(Image *image) in freeimage() argument
600 freebuffer(image); in freeimage()
601 png_image_free(&image->image); in freeimage()
603 if (image->input_file != NULL) in freeimage()
605 fclose(image->input_file); in freeimage()
606 image->input_file = NULL; in freeimage()
609 if (image->input_memory != NULL) in freeimage()
611 free(image->input_memory); in freeimage()
612 image->input_memory = NULL; in freeimage()
613 image->input_memory_size = 0; in freeimage()
616 if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0) in freeimage()
618 remove(image->tmpfile_name); in freeimage()
619 image->tmpfile_name[0] = 0; in freeimage()
626 static void initimage(Image *image, png_uint_32 opts, const char *file_name, in initimage() argument
629 freeimage(image); in initimage()
630 memset(&image->image, 0, sizeof image->image); in initimage()
631 image->opts = opts; in initimage()
632 image->file_name = file_name; in initimage()
633 image->stride_extra = stride_extra; in initimage()
641 allocbuffer(Image *image) in allocbuffer() argument
643 png_size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride); in allocbuffer()
645 if (size+32 > image->bufsize) in allocbuffer()
647 freebuffer(image); in allocbuffer()
648 image->buffer = voidcast(png_bytep, malloc(size+32)); in allocbuffer()
649 if (image->buffer == NULL) in allocbuffer()
657 image->bufsize = size+32; in allocbuffer()
660 memset(image->buffer, 95, image->bufsize); in allocbuffer()
661 memset(image->buffer+16, BUFFER_INIT8, size); in allocbuffer()
662 image->allocsize = size; in allocbuffer()
680 checkbuffer(Image *image, const char *arg) in checkbuffer() argument
682 if (check16(image->buffer, 95)) in checkbuffer()
689 if (check16(image->buffer+16+image->allocsize, 95)) in checkbuffer()
701 logerror(Image *image, const char *a1, const char *a2, const char *a3) in logerror() argument
704 if (image->image.warning_or_error) in logerror()
705 fprintf(stderr, "%s%s%s: %s\n", a1, a2, a3, image->image.message); in logerror()
710 if (image->image.opaque != NULL) in logerror()
713 image->file_name); in logerror()
714 png_image_free(&image->image); in logerror()
724 logclose(Image *image, FILE *f, const char *name, const char *operation) in logclose() argument
729 return logerror(image, name, operation, strerror(e)); in logclose()
736 checkopaque(Image *image) in checkopaque() argument
738 if (image->image.opaque != NULL) in checkopaque()
740 png_image_free(&image->image); in checkopaque()
741 return logerror(image, image->file_name, ": opaque not NULL", ""); in checkopaque()
744 else if (image->image.warning_or_error != 0 && (image->opts & STRICT) != 0) in checkopaque()
745 return logerror(image, image->file_name, " --strict", ""); in checkopaque()
2192 in_format = in_image->image.format; in transform_from_formats()
2193 out_format = out_image->image.format; in transform_from_formats()
2466 const png_uint_32 in_format = transform->in_image->image.format; in logpixel()
2467 const png_uint_32 out_format = transform->out_image->image.format; in logpixel()
2722 const png_uint_32 width = a->image.width; in compare_two_images()
2723 const png_uint_32 height = a->image.height; in compare_two_images()
2724 const png_uint_32 formata = a->image.format; in compare_two_images()
2725 const png_uint_32 formatb = b->image.format; in compare_two_images()
2735 if (width != b->image.width || height != b->image.height) in compare_two_images()
2817 if (y >= a->image.colormap_entries) in compare_two_images()
2823 (unsigned long)a->image.colormap_entries); in compare_two_images()
2829 else if (y >= b->image.colormap_entries) in compare_two_images()
2835 (unsigned long)b->image.colormap_entries); in compare_two_images()
2868 if (amax >= a->image.colormap_entries) in compare_two_images()
2872 (unsigned long)a->image.colormap_entries); in compare_two_images()
2876 else if (bmax >= b->image.colormap_entries) in compare_two_images()
2880 (unsigned long)b->image.colormap_entries); in compare_two_images()
3057 read_file(Image *image, png_uint_32 format, png_const_colorp background) in read_file() argument
3059 memset(&image->image, 0, sizeof image->image); in read_file()
3060 image->image.version = PNG_IMAGE_VERSION; in read_file()
3062 if (image->input_memory != NULL) in read_file()
3064 if (!png_image_begin_read_from_memory(&image->image, image->input_memory, in read_file()
3065 image->input_memory_size)) in read_file()
3066 return logerror(image, "memory init: ", image->file_name, ""); in read_file()
3070 else if (image->input_file != NULL) in read_file()
3072 if (!png_image_begin_read_from_stdio(&image->image, image->input_file)) in read_file()
3073 return logerror(image, "stdio init: ", image->file_name, ""); in read_file()
3078 if (!png_image_begin_read_from_file(&image->image, image->file_name)) in read_file()
3079 return logerror(image, "file init: ", image->file_name, ""); in read_file()
3084 return logerror(image, "unsupported file/stdio init: ", in read_file()
3085 image->file_name, ""); in read_file()
3090 if (image->opts & sRGB_16BIT) in read_file()
3091 image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB; in read_file()
3101 image_format = image->image.format; in read_file()
3103 if (image->opts & VERBOSE) in read_file()
3105 printf("%s %lu x %lu %s -> %s", image->file_name, in read_file()
3106 (unsigned long)image->image.width, in read_file()
3107 (unsigned long)image->image.height, in read_file()
3109 (format & FORMAT_NO_CHANGE) != 0 || image->image.format == format in read_file()
3135 image->image.format = format; in read_file()
3137 image->stride = PNG_IMAGE_ROW_STRIDE(image->image) + image->stride_extra; in read_file()
3138 allocbuffer(image); in read_file()
3140 result = png_image_finish_read(&image->image, background, in read_file()
3141 image->buffer+16, (png_int_32)image->stride, image->colormap); in read_file()
3143 checkbuffer(image, image->file_name); in read_file()
3146 return checkopaque(image); in read_file()
3149 return logerror(image, image->file_name, ": image read failed", ""); in read_file()
3158 read_one_file(Image *image) in read_one_file() argument
3160 if (!(image->opts & READ_FILE) || (image->opts & USE_STDIO)) in read_one_file()
3163 FILE *f = fopen(image->file_name, "rb"); in read_one_file()
3167 if (image->opts & READ_FILE) in read_one_file()
3168 image->input_file = f; in read_one_file()
3187 image->input_memory_size = cb; in read_one_file()
3188 image->input_memory = b; in read_one_file()
3194 return logclose(image, f, image->file_name, in read_one_file()
3200 return logclose(image, f, image->file_name, in read_one_file()
3205 return logclose(image, f, image->file_name, in read_one_file()
3209 return logclose(image, f, image->file_name, in read_one_file()
3214 return logclose(image, f, image->file_name, ": seek failed: "); in read_one_file()
3219 return logerror(image, image->file_name, ": open failed: ", in read_one_file()
3223 return read_file(image, FORMAT_NO_CHANGE, NULL); in read_one_file()
3228 write_one_file(Image *output, Image *image, int convert_to_8bit) in write_one_file() argument
3230 if (image->opts & FAST_WRITE) in write_one_file()
3231 image->image.flags |= PNG_IMAGE_FLAG_FAST; in write_one_file()
3233 if (image->opts & USE_STDIO) in write_one_file()
3239 if (png_image_write_to_stdio(&image->image, f, convert_to_8bit, in write_one_file()
3240 image->buffer+16, (png_int_32)image->stride, image->colormap)) in write_one_file()
3245 initimage(output, image->opts, "tmpfile", image->stride_extra); in write_one_file()
3247 if (!checkopaque(image)) in write_one_file()
3252 return logclose(image, f, "tmpfile", ": flush: "); in write_one_file()
3258 return logerror(image, "tmpfile", ": write failed", ""); in write_one_file()
3263 return logerror(image, "tmpfile", ": open: ", strerror(errno)); in write_one_file()
3273 if (png_image_write_to_file(&image->image, name, convert_to_8bit, in write_one_file()
3274 image->buffer+16, (png_int_32)image->stride, image->colormap)) in write_one_file()
3276 initimage(output, image->opts, output->tmpfile_name, in write_one_file()
3277 image->stride_extra); in write_one_file()
3281 if (!checkopaque(image)) in write_one_file()
3286 return logerror(image, name, ": write failed", ""); in write_one_file()
3296 if (read_file(output, image->image.format | FORMAT_NO_CHANGE, NULL)) in write_one_file()
3298 png_uint_32 original_format = image->image.format; in write_one_file()
3303 if ((output->image.format & BASE_FORMATS) != in write_one_file()
3305 return logerror(image, image->file_name, ": format changed on read: ", in write_one_file()
3308 return compare_two_images(image, output, 0/*via linear*/, NULL); in write_one_file()
3318 testimage(Image *image, png_uint_32 opts, format_list *pf) in testimage() argument
3324 checkopaque(image); in testimage()
3325 copy = *image; in testimage()
3332 image->input_file = NULL; in testimage()
3333 image->input_memory = NULL; in testimage()
3334 image->input_memory_size = 0; in testimage()
3335 image->tmpfile_name[0] = 0; in testimage()
3366 (image->image.format & PNG_FORMAT_FLAG_ALPHA) != 0) in testimage()
3399 result = compare_two_images(image, &copy, 0/*via linear*/, background); in testimage()
3416 result = compare_two_images(image, &output, 0, background); in testimage()
3439 result = compare_two_images(image, &output, 1/*via_linear*/, in testimage()
3460 Image image; in test_one_file() local
3462 newimage(&image); in test_one_file()
3463 initimage(&image, opts, file_name, stride_extra); in test_one_file()
3464 result = read_one_file(&image); in test_one_file()
3466 result = testimage(&image, opts, formats); in test_one_file()
3467 freeimage(&image); in test_one_file()