]>
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-2005 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 image_t
*img
; /* Image to print */
47 int primary
; /* Primary image colorspace */
48 FILE *out
; /* Output PPM/PGM file */
49 ib_t
*line
; /* Line from file */
50 int y
; /* Current line */
55 puts("Usage: testimage filename.ext filename.[ppm|pgm]");
59 if (strstr(argv
[2], ".ppm") != NULL
)
62 primary
= IMAGE_WHITE
;
64 img
= ImageOpen(argv
[1], primary
, IMAGE_WHITE
, 100, 0, NULL
);
72 out
= fopen(argv
[2], "wb");
81 line
= calloc(img
->xsize
, img
->colorspace
);
83 fprintf(out
, "P%d\n%d\n%d\n255\n", img
->colorspace
== IMAGE_WHITE
? 5 : 6,
84 img
->xsize
, img
->ysize
);
86 for (y
= 0; y
< img
->ysize
; y
++)
88 ImageGetRow(img
, 0, y
, img
->xsize
, line
);
89 fwrite(line
, img
->xsize
, img
->colorspace
, out
);
100 * End of "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $".