]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/testimage.c
2 * "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $"
4 * Image library test program for the Common UNIX Printing System (CUPS).
6 * Copyright 1993-2006 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * This file is subject to the Apple OS-Developed Software exception.
28 * main() - Main entry...
32 * Include necessary headers...
39 * 'main()' - Main entry...
42 int /* O - Exit status */
43 main(int argc
, /* I - Number of command-line arguments */
44 char *argv
[]) /* I - Command-line arguments */
46 cups_image_t
*img
; /* Image to print */
47 cups_icspace_t primary
; /* Primary image colorspace */
48 FILE *out
; /* Output PPM/PGM file */
49 cups_ib_t
*line
; /* Line from file */
50 int y
, /* Current line */
51 width
, /* Width of image */
52 height
, /* Height of image */
53 depth
; /* Depth of image */
58 puts("Usage: testimage filename.ext filename.[ppm|pgm]");
62 if (strstr(argv
[2], ".ppm") != NULL
)
63 primary
= CUPS_IMAGE_RGB
;
65 primary
= CUPS_IMAGE_WHITE
;
67 img
= cupsImageOpen(argv
[1], primary
, CUPS_IMAGE_WHITE
, 100, 0, NULL
);
75 out
= fopen(argv
[2], "wb");
84 width
= cupsImageGetWidth(img
);
85 height
= cupsImageGetHeight(img
);
86 depth
= cupsImageGetDepth(img
);
87 line
= calloc(width
, depth
);
89 fprintf(out
, "P%d\n%d\n%d\n255\n",
90 cupsImageGetColorSpace(img
) == CUPS_IMAGE_WHITE
? 5 : 6,
93 for (y
= 0; y
< height
; y
++)
95 cupsImageGetRow(img
, 0, y
, width
, line
);
96 fwrite(line
, width
, depth
, out
);
107 * End of "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $".