From e23345ad0b127502b96bfd3ded1cf6c1b8c0c608 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 8 Dec 2023 13:38:36 +0100 Subject: [PATCH] removed some #ifndef-ed code in cairo_jpg.c --- src/cairo_jpg.c | 89 ------------------------------------------------- 1 file changed, 89 deletions(-) diff --git a/src/cairo_jpg.c b/src/cairo_jpg.c index c5f68891..81e0ad46 100644 --- a/src/cairo_jpg.c +++ b/src/cairo_jpg.c @@ -540,94 +540,5 @@ cairo_surface_t *cairo_image_surface_create_from_jpeg(const char *filename) #endif - -#ifdef CAIRO_JPEG_MAIN -#include -#include - -int strrcasecmp(const char *s1, const char *s2) -{ - int off = (int) strlen(s1) - (int) strlen(s2); /* typecast size_t to int because size_t typically is unsigned */ - return strcasecmp(s1 + (off < 0 ? 0 : off), s2); -} - -/*! Main routine, only for testing. #undef CAIRO_JPEG_MAIN or simply delete - * this part if you link this file to your own program. - */ -int main(int argc, char **argv) -{ - cairo_surface_t *sfc; - -#ifndef CAIRO_JPEG_TEST_SIMILAR - if (argc < 3) - { - fprintf(stderr, "usage: %s \n", argv[0]); - return 1; - } - - /* test input file type and read file */ - if (!strrcasecmp(argv[1], ".png")) - { - /* read PNG file */ - sfc = cairo_image_surface_create_from_png(argv[1]); - } - else if (!strrcasecmp(argv[1], ".jpg")) - { - /* read JPEG file */ - sfc = cairo_image_surface_create_from_jpeg(argv[1]); - } - else - { - fprintf(stderr, "source file is neither JPG nor PNG\n"); - return 1; - } - - /* check surface status */ - if (cairo_surface_status(sfc) != CAIRO_STATUS_SUCCESS) - { - fprintf(stderr, "error loading image: %s", cairo_status_to_string(cairo_surface_status(sfc))); - return 2; - } - - /* test output file type and write file */ - if (!strrcasecmp(argv[2], ".png")) - { - /* write PNG file */ - cairo_surface_write_to_png(sfc, argv[2]); - } - else if (!strrcasecmp(argv[2], ".jpg")) - { - /* write JPEG file */ - cairo_image_surface_write_to_jpeg(sfc, argv[2], 90); - } - else - { - fprintf(stderr, "destination file is neither JPG nor PNG\n"); - return 1; - } - - cairo_surface_destroy(sfc); - -#else - sfc = cairo_pdf_surface_create("xyz.pdf", 595.276, 841.890); - - cairo_t *ctx = cairo_create(sfc); - cairo_set_source_rgb(ctx, 1, 1, 1); - cairo_paint(ctx); - cairo_move_to(ctx, 100, 100); - cairo_set_source_rgb(ctx, 1, 0, 0); - cairo_set_line_width(ctx, 3); - cairo_line_to(ctx, 400, 400); - cairo_stroke(ctx); - cairo_destroy(ctx); - - cairo_image_surface_write_to_jpeg(sfc, "xyz.jpg", 90); - cairo_surface_destroy(sfc); -#endif - - return 0; -} - -#endif #endif /* HAS_LIBJPEG && HAS_CAIRO */ typedef int make_iso_compilers_happy; /* to avoid empty translation unit */