removed some #ifndef-ed code in cairo_jpg.c

This commit is contained in:
stefan schippers 2023-12-08 13:38:36 +01:00
parent 1e9d189ad4
commit e23345ad0b
1 changed files with 0 additions and 89 deletions

View File

@ -540,94 +540,5 @@ cairo_surface_t *cairo_image_surface_create_from_jpeg(const char *filename)
#endif
#ifdef CAIRO_JPEG_MAIN
#include <string.h>
#include <strings.h>
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 <infile> <outfile>\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 */