]> git.ipfire.org Git - thirdparty/cups.git/blame - filter/testimage.c
Load cups into easysw/current.
[thirdparty/cups.git] / filter / testimage.c
CommitLineData
ef416fc2 1/*
2 * "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $"
3 *
4 * Image library test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1993-2005 by Easy Software Products.
7 *
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
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * This file is subject to the Apple OS-Developed Software exception.
25 *
26 * Contents:
27 *
28 * main() - Main entry...
29 */
30
31/*
32 * Include necessary headers...
33 */
34
35#include "image.h"
36
37
38/*
39 * 'main()' - Main entry...
40 */
41
42int /* O - Exit status */
43main(int argc, /* I - Number of command-line arguments */
44 char *argv[]) /* I - Command-line arguments */
45{
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 */
51
52
53 if (argc != 3)
54 {
55 puts("Usage: testimage filename.ext filename.[ppm|pgm]");
56 return (1);
57 }
58
59 if (strstr(argv[2], ".ppm") != NULL)
60 primary = IMAGE_RGB;
61 else
62 primary = IMAGE_WHITE;
63
64 img = ImageOpen(argv[1], primary, IMAGE_WHITE, 100, 0, NULL);
65
66 if (!img)
67 {
68 perror(argv[1]);
69 return (1);
70 }
71
72 out = fopen(argv[2], "wb");
73
74 if (!out)
75 {
76 perror(argv[2]);
77 ImageClose(img);
78 return (1);
79 }
80
81 line = calloc(img->xsize, img->colorspace);
82
83 fprintf(out, "P%d\n%d\n%d\n255\n", img->colorspace == IMAGE_WHITE ? 5 : 6,
84 img->xsize, img->ysize);
85
86 for (y = 0; y < img->ysize; y ++)
87 {
88 ImageGetRow(img, 0, y, img->xsize, line);
89 fwrite(line, img->xsize, img->colorspace, out);
90 }
91
92 ImageClose(img);
93 fclose(out);
94
95 return (0);
96}
97
98
99/*
100 * End of "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $".
101 */