1TIFFReadRGBATile(3TIFF) TIFFReadRGBATile(3TIFF)
2
3
4
6 TIFFReadRGBATile - read and decode an image tile into a fixed-format
7 raster
8
10 #include <tiffio.h>
11
12 #define TIFFGetR(abgr) ((abgr) & 0xff)
13 #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
14 #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
15 #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
16
17 int TIFFReadRGBATile(TIFF *tif, uint32_t x, uint32_t y, uint32_t
18 *raster)
19
21 TIFFReadRGBATile reads a single tile of a tile-based image into memory,
22 storing the result in the user supplied RGBA raster. The raster is as‐
23 sumed to be an array of width times length 32-bit entries, where width
24 is the width of a tile (TIFFTAG_TILEWIDTH) and length is the height of
25 a tile (TIFFTAG_TILELENGTH).
26
27
28 The x and y values are the offsets from the top left corner to the top
29 left corner of the tile to be read. They must be an exact multiple of
30 the tile width and length.
31
32
33 Note that the raster is assume to be organized such that the pixel at
34 location (x,y) is raster[y*width+x]; with the raster origin in the
35 lower-left hand corner of the tile. That is bottom to top organization.
36 Edge tiles which partly fall off the image will be filled out with ap‐
37 propriate zeroed areas.
38
39
40 Raster pixels are 8-bit packed red, green, blue, alpha samples. The
41 macros TIFFGetR, TIFFGetG, TIFFGetB, and TIFFGetA should be used to ac‐
42 cess individual samples. Images without Associated Alpha matting infor‐
43 mation have a constant Alpha of 1.0 (255).
44
45 See the TIFFRGBAImage(3TIFF) page for more details on how various image
46 types are converted to RGBA values.
47
49 Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric sam‐
50 ples/pixel must be either 1, 3, or 4 (i.e. SamplesPerPixel minus Ex‐
51 traSamples).
52
53 Palette image colormaps that appear to be incorrectly written as 8-bit
54 values are automatically scaled to 16-bits.
55
56 TIFFReadRGBATile is just a wrapper around the more general TIFFRGBAIm‐
57 age(3TIFF) facilities. It's main advantage over the similar TIFFRead‐
58 RGBAImage() function is that for large images a single buffer capable
59 of holding the whole image doesn't need to be allocated, only enough
60 for one tile. The TIFFReadRGBAStrip() function does a similar opera‐
61 tion for stripped images.
62
64 1 is returned if the image was successfully read and converted. Other‐
65 wise, 0 is returned if an error was encountered.
66
68 All error messages are directed to the TIFFError(3TIFF) routine.
69
70 Sorry, can not handle %d-bit pictures. The image had BitsPerSample
71 other than 1, 2, 4, 8, or 16.
72
73 Sorry, can not handle %d-channel images. The image had SamplesPerPixel
74 other than 1, 3, or 4.
75
76 Missing needed "PhotometricInterpretation" tag. The image did not have
77 a tag that describes how to display the data.
78
79 No "PhotometricInterpretation" tag, assuming RGB. The image was miss‐
80 ing a tag that describes how to display it, but because it has 3 or 4
81 samples/pixel, it is assumed to be RGB.
82
83 No "PhotometricInterpretation" tag, assuming min-is-black. The image
84 was missing a tag that describes how to display it, but because it has
85 1 sample/pixel, it is assumed to be a grayscale or bilevel image.
86
87 No space for photometric conversion table. There was insufficient mem‐
88 ory for a table used to convert image samples to 8-bit RGB.
89
90 Missing required "Colormap" tag. A Palette image did not have a re‐
91 quired Colormap tag.
92
93 No space for tile buffer. There was insufficient memory to allocate an
94 i/o buffer.
95
96 No space for strip buffer. There was insufficient memory to allocate
97 an i/o buffer.
98
99 Can not handle format. The image has a format (combination of BitsPer‐
100 Sample, SamplesPerPixel, and PhotometricInterpretation) that TIFFRead‐
101 RGBAImage can not handle.
102
103 No space for B&W mapping table. There was insufficient memory to allo‐
104 cate a table used to map grayscale data to RGB.
105
106 No space for Palette mapping table. There was insufficient memory to
107 allocate a table used to map data to 8-bit RGB.
108
110 TIFFOpen(3TIFF), TIFFRGBAImage(3TIFF), TIFFReadRGBAImage(3TIFF), TIFF‐
111 ReadRGBAStrip(3TIFF), libtiff(3TIFF)
112
113 Libtiff library home page: http://www.simplesystems.org/libtiff/
114
115
116
117libtiff December 10, 1998 TIFFReadRGBATile(3TIFF)