Lines Matching refs:image

576    png_image   image;  member
594 newimage(Image *image) in newimage() argument
596 memset(image, 0, sizeof *image); in newimage()
602 resetimage(Image *image) in resetimage() argument
604 if (image->input_file != NULL) in resetimage()
605 rewind(image->input_file); in resetimage()
612 freebuffer(Image *image) in freebuffer() argument
614 if (image->buffer) free(image->buffer); in freebuffer()
615 image->buffer = NULL; in freebuffer()
616 image->bufsize = 0; in freebuffer()
617 image->allocsize = 0; in freebuffer()
624 freeimage(Image *image) in freeimage() argument
626 freebuffer(image); in freeimage()
627 png_image_free(&image->image); in freeimage()
629 if (image->input_file != NULL) in freeimage()
631 fclose(image->input_file); in freeimage()
632 image->input_file = NULL; in freeimage()
635 if (image->input_memory != NULL) in freeimage()
637 free(image->input_memory); in freeimage()
638 image->input_memory = NULL; in freeimage()
639 image->input_memory_size = 0; in freeimage()
642 if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0) in freeimage()
644 (void)remove(image->tmpfile_name); in freeimage()
645 image->tmpfile_name[0] = 0; in freeimage()
652 static void initimage(Image *image, png_uint_32 opts, const char *file_name, in initimage() argument
655 freeimage(image); in initimage()
656 memset(&image->image, 0, sizeof image->image); in initimage()
657 image->opts = opts; in initimage()
658 image->file_name = file_name; in initimage()
659 image->stride_extra = stride_extra; in initimage()
667 allocbuffer(Image *image) in allocbuffer() argument
669 png_size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride); in allocbuffer()
671 if (size+32 > image->bufsize) in allocbuffer()
673 freebuffer(image); in allocbuffer()
674 image->buffer = voidcast(png_bytep, malloc(size+32)); in allocbuffer()
675 if (image->buffer == NULL) in allocbuffer()
683 image->bufsize = size+32; in allocbuffer()
686 memset(image->buffer, 95, image->bufsize); in allocbuffer()
687 memset(image->buffer+16, BUFFER_INIT8, size); in allocbuffer()
688 image->allocsize = size; in allocbuffer()
706 checkbuffer(Image *image, const char *arg) in checkbuffer() argument
708 if (check16(image->buffer, 95)) in checkbuffer()
715 if (check16(image->buffer+16+image->allocsize, 95)) in checkbuffer()
727 logerror(Image *image, const char *a1, const char *a2, const char *a3) in logerror() argument
730 if (image->image.warning_or_error) in logerror()
731 fprintf(stderr, "%s%s%s: %s\n", a1, a2, a3, image->image.message); in logerror()
736 if (image->image.opaque != NULL) in logerror()
739 image->file_name); in logerror()
740 png_image_free(&image->image); in logerror()
750 logclose(Image *image, FILE *f, const char *name, const char *operation) in logclose() argument
755 return logerror(image, name, operation, strerror(e)); in logclose()
762 checkopaque(Image *image) in checkopaque() argument
764 if (image->image.opaque != NULL) in checkopaque()
766 png_image_free(&image->image); in checkopaque()
767 return logerror(image, image->file_name, ": opaque not NULL", ""); in checkopaque()
773 else if (image->image.warning_or_error != 0 && in checkopaque()
774 (strcmp(image->image.message, in checkopaque()
776 (image->opts & GBG_ERROR) != 0 : (image->opts & STRICT) != 0)) in checkopaque()
777 return logerror(image, image->file_name, (image->opts & GBG_ERROR) != 0 ? in checkopaque()
2076 in_format = in_image->image.format; in transform_from_formats()
2077 out_format = out_image->image.format; in transform_from_formats()
2350 const png_uint_32 in_format = transform->in_image->image.format; in logpixel()
2351 const png_uint_32 out_format = transform->out_image->image.format; in logpixel()
2606 const png_uint_32 width = a->image.width; in compare_two_images()
2607 const png_uint_32 height = a->image.height; in compare_two_images()
2608 const png_uint_32 formata = a->image.format; in compare_two_images()
2609 const png_uint_32 formatb = b->image.format; in compare_two_images()
2619 if (width != b->image.width || height != b->image.height) in compare_two_images()
2701 if (y >= a->image.colormap_entries) in compare_two_images()
2707 (unsigned long)a->image.colormap_entries); in compare_two_images()
2713 else if (y >= b->image.colormap_entries) in compare_two_images()
2719 (unsigned long)b->image.colormap_entries); in compare_two_images()
2752 if (amax >= a->image.colormap_entries) in compare_two_images()
2756 (unsigned long)a->image.colormap_entries); in compare_two_images()
2760 else if (bmax >= b->image.colormap_entries) in compare_two_images()
2764 (unsigned long)b->image.colormap_entries); in compare_two_images()
2941 read_file(Image *image, png_uint_32 format, png_const_colorp background) in read_file() argument
2943 memset(&image->image, 0, sizeof image->image); in read_file()
2944 image->image.version = PNG_IMAGE_VERSION; in read_file()
2946 if (image->input_memory != NULL) in read_file()
2948 if (!png_image_begin_read_from_memory(&image->image, image->input_memory, in read_file()
2949 image->input_memory_size)) in read_file()
2950 return logerror(image, "memory init: ", image->file_name, ""); in read_file()
2954 else if (image->input_file != NULL) in read_file()
2956 if (!png_image_begin_read_from_stdio(&image->image, image->input_file)) in read_file()
2957 return logerror(image, "stdio init: ", image->file_name, ""); in read_file()
2962 if (!png_image_begin_read_from_file(&image->image, image->file_name)) in read_file()
2963 return logerror(image, "file init: ", image->file_name, ""); in read_file()
2968 return logerror(image, "unsupported file/stdio init: ", in read_file()
2969 image->file_name, ""); in read_file()
2974 if (image->opts & sRGB_16BIT) in read_file()
2975 image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB; in read_file()
2985 image_format = image->image.format; in read_file()
2987 if (image->opts & VERBOSE) in read_file()
2989 printf("%s %lu x %lu %s -> %s", image->file_name, in read_file()
2990 (unsigned long)image->image.width, in read_file()
2991 (unsigned long)image->image.height, in read_file()
2993 (format & FORMAT_NO_CHANGE) != 0 || image->image.format == format in read_file()
3019 image->image.format = format; in read_file()
3021 image->stride = PNG_IMAGE_ROW_STRIDE(image->image) + image->stride_extra; in read_file()
3022 allocbuffer(image); in read_file()
3024 result = png_image_finish_read(&image->image, background, in read_file()
3025 image->buffer+16, (png_int_32)image->stride, image->colormap); in read_file()
3027 checkbuffer(image, image->file_name); in read_file()
3030 return checkopaque(image); in read_file()
3033 return logerror(image, image->file_name, ": image read failed", ""); in read_file()
3042 read_one_file(Image *image) in read_one_file() argument
3044 if (!(image->opts & USE_FILE) || (image->opts & USE_STDIO)) in read_one_file()
3047 FILE *f = fopen(image->file_name, "rb"); in read_one_file()
3051 if (image->opts & USE_FILE) in read_one_file()
3052 image->input_file = f; in read_one_file()
3075 image->input_memory_size = cb; in read_one_file()
3076 image->input_memory = b; in read_one_file()
3082 return logclose(image, f, image->file_name, in read_one_file()
3088 return logclose(image, f, image->file_name, in read_one_file()
3093 return logclose(image, f, image->file_name, in read_one_file()
3102 return logclose(image, f, image->file_name, in read_one_file()
3106 return logclose(image, f, image->file_name, in read_one_file()
3111 return logclose(image, f, image->file_name, ": seek failed: "); in read_one_file()
3116 return logerror(image, image->file_name, ": open failed: ", in read_one_file()
3120 return read_file(image, FORMAT_NO_CHANGE, NULL); in read_one_file()
3125 write_one_file(Image *output, Image *image, int convert_to_8bit) in write_one_file() argument
3127 if (image->opts & FAST_WRITE) in write_one_file()
3128 image->image.flags |= PNG_IMAGE_FLAG_FAST; in write_one_file()
3130 if (image->opts & USE_STDIO) in write_one_file()
3170 if (png_image_write_to_stdio(&image->image, f, convert_to_8bit, in write_one_file()
3171 image->buffer+16, (png_int_32)image->stride, image->colormap)) in write_one_file()
3176 initimage(output, image->opts, "tmpfile", image->stride_extra); in write_one_file()
3178 if (!checkopaque(image)) in write_one_file()
3183 return logclose(image, f, "tmpfile", ": flush: "); in write_one_file()
3189 return logerror(image, "tmpfile", ": write failed", ""); in write_one_file()
3194 return logerror(image, "tmpfile", ": open: ", strerror(errno)); in write_one_file()
3196 return logerror(image, "tmpfile", ": open: unsupported", ""); in write_one_file()
3200 else if (image->opts & USE_FILE) in write_one_file()
3208 if (png_image_write_to_file(&image->image, name, convert_to_8bit, in write_one_file()
3209 image->buffer+16, (png_int_32)image->stride, image->colormap)) in write_one_file()
3211 initimage(output, image->opts, output->tmpfile_name, in write_one_file()
3212 image->stride_extra); in write_one_file()
3216 if (!checkopaque(image)) in write_one_file()
3221 return logerror(image, name, ": write failed", ""); in write_one_file()
3223 return logerror(image, "stdio", ": open: unsupported", ""); in write_one_file()
3231 if (png_image_write_get_memory_size(image->image, size, convert_to_8bit, in write_one_file()
3232 image->buffer+16, (png_int_32)image->stride, image->colormap)) in write_one_file()
3237 if (size > PNG_IMAGE_PNG_SIZE_MAX(image->image)) in write_one_file()
3238 return logerror(image, "memory", ": PNG_IMAGE_SIZE_MAX wrong", ""); in write_one_file()
3240 initimage(output, image->opts, "memory", image->stride_extra); in write_one_file()
3247 if (png_image_write_to_memory(&image->image, output->input_memory, in write_one_file()
3248 &output->input_memory_size, convert_to_8bit, image->buffer+16, in write_one_file()
3249 (png_int_32)image->stride, image->colormap)) in write_one_file()
3254 return logerror(image, "memory", ": memory size wrong", ""); in write_one_file()
3258 return logerror(image, "memory", ": write failed", ""); in write_one_file()
3262 return logerror(image, "memory", ": out of memory", ""); in write_one_file()
3266 return logerror(image, "memory", ": get size:", ""); in write_one_file()
3276 if (read_file(output, image->image.format | FORMAT_NO_CHANGE, NULL)) in write_one_file()
3278 png_uint_32 original_format = image->image.format; in write_one_file()
3283 if ((output->image.format & BASE_FORMATS) != in write_one_file()
3285 return logerror(image, image->file_name, ": format changed on read: ", in write_one_file()
3288 return compare_two_images(image, output, 0/*via linear*/, NULL); in write_one_file()
3298 testimage(Image *image, png_uint_32 opts, format_list *pf) in testimage() argument
3304 checkopaque(image); in testimage()
3305 copy = *image; in testimage()
3312 image->input_file = NULL; in testimage()
3313 image->input_memory = NULL; in testimage()
3314 image->input_memory_size = 0; in testimage()
3315 image->tmpfile_name[0] = 0; in testimage()
3346 (image->image.format & PNG_FORMAT_FLAG_ALPHA) != 0) in testimage()
3379 result = compare_two_images(image, &copy, 0/*via linear*/, background); in testimage()
3396 result = compare_two_images(image, &output, 0, background); in testimage()
3419 result = compare_two_images(image, &output, 1/*via_linear*/, in testimage()
3440 Image image; in test_one_file() local
3444 newimage(&image); in test_one_file()
3445 initimage(&image, opts, file_name, stride_extra); in test_one_file()
3446 result = read_one_file(&image); in test_one_file()
3448 result = testimage(&image, opts, formats); in test_one_file()
3449 freeimage(&image); in test_one_file()