]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/test/strip_rw.c
Don't use DDEExec registry key in wxMSW wxExecute() if it's empty.
[wxWidgets.git] / src / tiff / test / strip_rw.c
1
2 /*
3 * Copyright (c) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
12 *
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
23 */
24
25 /*
26 * TIFF Library
27 *
28 * Test libtiff input/output routines.
29 */
30
31 #include "tif_config.h"
32
33 #include <stdio.h>
34
35 #ifdef HAVE_UNISTD_H
36 # include <unistd.h>
37 #endif
38
39 #include "tiffio.h"
40 #include "test_arrays.h"
41
42 extern int
43 create_image_striped(const char *, uint32, uint32, uint32, uint16, uint16,
44 uint16, uint16, uint16, uint16, const tdata_t,
45 const tsize_t);
46 extern int
47 read_image_striped(const char *, uint32, uint32, uint32, uint16, uint16,
48 uint16, uint16, uint16, uint16, const tdata_t,
49 const tsize_t);
50
51 const char *filename = "strip_test.tiff";
52
53 int
54 main(int argc, char **argv)
55 {
56 uint32 rowsperstrip;
57 uint16 compression;
58 uint16 spp, bps, photometric, sampleformat, planarconfig;
59 (void) argc;
60 (void) argv;
61
62 /*
63 * Test two special cases: image consisting from single line and image
64 * consisting from single column.
65 */
66 rowsperstrip = 1;
67 compression = COMPRESSION_NONE;
68 spp = 1;
69 bps = 8;
70 photometric = PHOTOMETRIC_MINISBLACK;
71 sampleformat = SAMPLEFORMAT_UINT;
72 planarconfig = PLANARCONFIG_CONTIG;
73
74 if (create_image_striped(filename, XSIZE * YSIZE, 1, rowsperstrip,
75 compression, spp, bps, photometric,
76 sampleformat, planarconfig,
77 (const tdata_t) byte_array1, byte_array1_size) < 0) {
78 fprintf (stderr, "Can't create TIFF file %s.\n", filename);
79 goto failure;
80 }
81 if (read_image_striped(filename, XSIZE * YSIZE, 1, rowsperstrip,
82 compression, spp, bps, photometric,
83 sampleformat, planarconfig,
84 (const tdata_t) byte_array1, byte_array1_size) < 0) {
85 fprintf (stderr, "Can't read TIFF file %s.\n", filename);
86 goto failure;
87 }
88 unlink(filename);
89
90 if (create_image_striped(filename, 1, XSIZE * YSIZE, rowsperstrip,
91 compression, spp, bps, photometric,
92 sampleformat, planarconfig,
93 (const tdata_t) byte_array1, byte_array1_size) < 0) {
94 fprintf (stderr, "Can't create TIFF file %s.\n", filename);
95 goto failure;
96 }
97 if (read_image_striped(filename, 1, XSIZE * YSIZE, rowsperstrip,
98 compression, spp, bps, photometric,
99 sampleformat, planarconfig,
100 (const tdata_t) byte_array1, byte_array1_size) < 0) {
101 fprintf (stderr, "Can't read TIFF file %s.\n", filename);
102 goto failure;
103 }
104 unlink(filename);
105
106 /*
107 * Test one-channel image with different parameters.
108 */
109 rowsperstrip = 1;
110 spp = 1;
111 bps = 8;
112 photometric = PHOTOMETRIC_MINISBLACK;
113 sampleformat = SAMPLEFORMAT_UINT;
114 planarconfig = PLANARCONFIG_CONTIG;
115
116 if (create_image_striped(filename, XSIZE, YSIZE, rowsperstrip,
117 compression, spp, bps, photometric,
118 sampleformat, planarconfig,
119 (const tdata_t) byte_array1, byte_array1_size) < 0) {
120 fprintf (stderr, "Can't create TIFF file %s.\n", filename);
121 goto failure;
122 }
123 if (read_image_striped(filename, XSIZE, YSIZE, rowsperstrip,
124 compression, spp, bps, photometric,
125 sampleformat, planarconfig,
126 (const tdata_t) byte_array1, byte_array1_size) < 0) {
127 fprintf (stderr, "Can't read TIFF file %s.\n", filename);
128 goto failure;
129 }
130 unlink(filename);
131
132 rowsperstrip = YSIZE;
133 if (create_image_striped(filename, XSIZE, YSIZE, rowsperstrip,
134 compression, spp, bps, photometric,
135 sampleformat, planarconfig,
136 (const tdata_t) byte_array1, byte_array1_size) < 0) {
137 fprintf (stderr, "Can't create TIFF file %s.\n", filename);
138 goto failure;
139 }
140 if (read_image_striped(filename, XSIZE, YSIZE, rowsperstrip,
141 compression, spp, bps, photometric,
142 sampleformat, planarconfig,
143 (const tdata_t) byte_array1, byte_array1_size) < 0) {
144 fprintf (stderr, "Can't read TIFF file %s.\n", filename);
145 goto failure;
146 }
147 unlink(filename);
148
149 return 0;
150
151 failure:
152 unlink(filename);
153 return 1;
154 }
155
156 /* vim: set ts=8 sts=8 sw=8 noet: */