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