]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <!-- Copyright 2008 Lubomir Bourdev and Hailin Jin |
2 | ||
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at | |
5 | http://www.boost.org/LICENSE_1_0.txt) | |
6 | --> | |
7 | ||
8 | <!-- | |
9 | Copyright 2005-2007 Adobe Systems Incorporated | |
10 | Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt | |
11 | or a copy at http://stlab.adobe.com/licenses.html) | |
12 | ||
13 | Some files are held under additional license. | |
14 | Please see "http://stlab.adobe.com/licenses.html" for more information. | |
15 | --> | |
16 | ||
17 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
18 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
19 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |
20 | ||
21 | <head> | |
22 | <TITLE>Generic Image Library: tiff_io.hpp Source File</TITLE> | |
23 | <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/> | |
24 | <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/> | |
25 | </head> | |
26 | <body> | |
27 | <table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr> | |
28 | <td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'> | |
29 | <div class="qindex"><a class="qindex" href="index.html">Modules</a> | |
30 | | <a class="qindex" href="classes.html">Alphabetical List</a> | |
31 | | <a class="qindex" href="annotated.html">Class List</a> | |
32 | | <a class="qindex" href="dirs.html">Directories</a> | |
33 | | <a class="qindex" href="files.html">File List</a> | |
34 | | <a class="qindex" href="../index.html">GIL Home Page</a> | |
35 | </div> | |
36 | <!-- End Header --> | |
37 | <!-- Generated by Doxygen 1.5.6 --> | |
38 | <div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a> » <a class="el" href="g_i_l_0079.html">gil</a> » <a class="el" href="g_i_l_0078.html">extension</a> » <a class="el" href="g_i_l_0077.html">io</a> | |
39 | </div> | |
40 | <div class="contents"> | |
41 | <h1>tiff_io.hpp</h1><a href="tiff__io_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> | |
42 | <a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2007 Adobe Systems Incorporated</span> | |
43 | <a name="l00003"></a>00003 <span class="comment"> </span> | |
44 | <a name="l00004"></a>00004 <span class="comment"> Use, modification and distribution are subject to the Boost Software License,</span> | |
45 | <a name="l00005"></a>00005 <span class="comment"> Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span> | |
46 | <a name="l00006"></a>00006 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt).</span> | |
47 | <a name="l00007"></a>00007 <span class="comment"></span> | |
48 | <a name="l00008"></a>00008 <span class="comment"> See http://opensource.adobe.com/gil for most recent version including documentation.</span> | |
49 | <a name="l00009"></a>00009 <span class="comment">*/</span> | |
50 | <a name="l00010"></a>00010 | |
51 | <a name="l00011"></a>00011 <span class="comment">/*************************************************************************************************/</span> | |
52 | <a name="l00012"></a>00012 | |
53 | <a name="l00013"></a>00013 <span class="preprocessor">#ifndef GIL_TIFF_IO_H</span> | |
54 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_TIFF_IO_H</span> | |
55 | <a name="l00015"></a>00015 <span class="preprocessor"></span> | |
56 | <a name="l00022"></a>00022 | |
57 | <a name="l00023"></a>00023 <span class="preprocessor">#include <vector></span> | |
58 | <a name="l00024"></a>00024 <span class="preprocessor">#include <string></span> | |
59 | <a name="l00025"></a>00025 <span class="preprocessor">#include <algorithm></span> | |
60 | <a name="l00026"></a>00026 <span class="preprocessor">#include <boost/static_assert.hpp></span> | |
61 | <a name="l00027"></a>00027 <span class="preprocessor">#include <tiffio.h></span> | |
62 | <a name="l00028"></a>00028 <span class="preprocessor">#include "../../gil_all.hpp"</span> | |
63 | <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="io__error_8hpp.html" title="Handle input-output errors.">io_error.hpp</a>"</span> | |
64 | <a name="l00030"></a>00030 | |
65 | <a name="l00031"></a>00031 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { | |
66 | <a name="l00032"></a>00032 | |
67 | <a name="l00033"></a>00033 <span class="keyword">namespace </span>detail { | |
68 | <a name="l00034"></a>00034 | |
69 | <a name="l00035"></a>00035 <span class="keyword">template</span> <<span class="keyword">typename</span> Channel,<span class="keyword">typename</span> ColorSpace> | |
70 | <a name="l00036"></a>00036 <span class="keyword">struct </span>tiff_read_support_private { | |
71 | <a name="l00037"></a>00037 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">false</span>); | |
72 | <a name="l00038"></a>00038 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=0); | |
73 | <a name="l00039"></a>00039 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=0); | |
74 | <a name="l00040"></a>00040 }; | |
75 | <a name="l00041"></a>00041 <span class="keyword">template</span> <> | |
76 | <a name="l00042"></a>00042 <span class="keyword">struct </span>tiff_read_support_private<bits8,gray_t> { | |
77 | <a name="l00043"></a>00043 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
78 | <a name="l00044"></a>00044 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8); | |
79 | <a name="l00045"></a>00045 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK); | |
80 | <a name="l00046"></a>00046 }; | |
81 | <a name="l00047"></a>00047 <span class="keyword">template</span> <> | |
82 | <a name="l00048"></a>00048 <span class="keyword">struct </span>tiff_read_support_private<bits8,rgb_t> { | |
83 | <a name="l00049"></a>00049 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
84 | <a name="l00050"></a>00050 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8); | |
85 | <a name="l00051"></a>00051 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB); | |
86 | <a name="l00052"></a>00052 }; | |
87 | <a name="l00053"></a>00053 <span class="keyword">template</span> <> | |
88 | <a name="l00054"></a>00054 <span class="keyword">struct </span>tiff_read_support_private<bits16,gray_t> { | |
89 | <a name="l00055"></a>00055 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
90 | <a name="l00056"></a>00056 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16); | |
91 | <a name="l00057"></a>00057 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK); | |
92 | <a name="l00058"></a>00058 }; | |
93 | <a name="l00059"></a>00059 <span class="keyword">template</span> <> | |
94 | <a name="l00060"></a>00060 <span class="keyword">struct </span>tiff_read_support_private<bits16,rgb_t> { | |
95 | <a name="l00061"></a>00061 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
96 | <a name="l00062"></a>00062 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16); | |
97 | <a name="l00063"></a>00063 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB); | |
98 | <a name="l00064"></a>00064 }; | |
99 | <a name="l00065"></a>00065 <span class="keyword">template</span> <> | |
100 | <a name="l00066"></a>00066 <span class="keyword">struct </span>tiff_read_support_private<bits32f,gray_t> { | |
101 | <a name="l00067"></a>00067 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
102 | <a name="l00068"></a>00068 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32); | |
103 | <a name="l00069"></a>00069 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK); | |
104 | <a name="l00070"></a>00070 }; | |
105 | <a name="l00071"></a>00071 <span class="keyword">template</span> <> | |
106 | <a name="l00072"></a>00072 <span class="keyword">struct </span>tiff_read_support_private<bits32f,rgb_t> { | |
107 | <a name="l00073"></a>00073 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
108 | <a name="l00074"></a>00074 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32); | |
109 | <a name="l00075"></a>00075 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB); | |
110 | <a name="l00076"></a>00076 }; | |
111 | <a name="l00077"></a>00077 | |
112 | <a name="l00078"></a>00078 <span class="keyword">template</span> <<span class="keyword">typename</span> Channel,<span class="keyword">typename</span> ColorSpace> | |
113 | <a name="l00079"></a>00079 <span class="keyword">struct </span>tiff_write_support_private { | |
114 | <a name="l00080"></a>00080 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">false</span>); | |
115 | <a name="l00081"></a>00081 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=0); | |
116 | <a name="l00082"></a>00082 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=0); | |
117 | <a name="l00083"></a>00083 }; | |
118 | <a name="l00084"></a>00084 <span class="keyword">template</span> <> | |
119 | <a name="l00085"></a>00085 <span class="keyword">struct </span>tiff_write_support_private<bits8,gray_t> { | |
120 | <a name="l00086"></a>00086 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
121 | <a name="l00087"></a>00087 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8); | |
122 | <a name="l00088"></a>00088 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK); | |
123 | <a name="l00089"></a>00089 }; | |
124 | <a name="l00090"></a>00090 <span class="keyword">template</span> <> | |
125 | <a name="l00091"></a>00091 <span class="keyword">struct </span>tiff_write_support_private<bits8,rgb_t> { | |
126 | <a name="l00092"></a>00092 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
127 | <a name="l00093"></a>00093 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8); | |
128 | <a name="l00094"></a>00094 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB); | |
129 | <a name="l00095"></a>00095 }; | |
130 | <a name="l00096"></a>00096 <span class="keyword">template</span> <> | |
131 | <a name="l00097"></a>00097 <span class="keyword">struct </span>tiff_write_support_private<bits16,gray_t> { | |
132 | <a name="l00098"></a>00098 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
133 | <a name="l00099"></a>00099 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16); | |
134 | <a name="l00100"></a>00100 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK); | |
135 | <a name="l00101"></a>00101 }; | |
136 | <a name="l00102"></a>00102 <span class="keyword">template</span> <> | |
137 | <a name="l00103"></a>00103 <span class="keyword">struct </span>tiff_write_support_private<bits16,rgb_t> { | |
138 | <a name="l00104"></a>00104 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
139 | <a name="l00105"></a>00105 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16); | |
140 | <a name="l00106"></a>00106 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB); | |
141 | <a name="l00107"></a>00107 }; | |
142 | <a name="l00108"></a>00108 <span class="keyword">template</span> <> | |
143 | <a name="l00109"></a>00109 <span class="keyword">struct </span>tiff_write_support_private<bits32f,gray_t> { | |
144 | <a name="l00110"></a>00110 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
145 | <a name="l00111"></a>00111 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32); | |
146 | <a name="l00112"></a>00112 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK); | |
147 | <a name="l00113"></a>00113 }; | |
148 | <a name="l00114"></a>00114 <span class="keyword">template</span> <> | |
149 | <a name="l00115"></a>00115 <span class="keyword">struct </span>tiff_write_support_private<bits32f,rgb_t> { | |
150 | <a name="l00116"></a>00116 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>); | |
151 | <a name="l00117"></a>00117 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32); | |
152 | <a name="l00118"></a>00118 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB); | |
153 | <a name="l00119"></a>00119 }; | |
154 | <a name="l00120"></a>00120 | |
155 | <a name="l00121"></a>00121 <span class="keyword">class </span>tiff_reader { | |
156 | <a name="l00122"></a>00122 <span class="keyword">protected</span>: | |
157 | <a name="l00123"></a>00123 TIFF *_tp; | |
158 | <a name="l00124"></a>00124 <span class="keyword">public</span>: | |
159 | <a name="l00125"></a>00125 tiff_reader(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) { | |
160 | <a name="l00126"></a>00126 io_error_if((_tp=TIFFOpen(filename,<span class="stringliteral">"r"</span>))==NULL, | |
161 | <a name="l00127"></a>00127 <span class="stringliteral">"tiff_reader: fail to open file"</span>); | |
162 | <a name="l00128"></a>00128 } | |
163 | <a name="l00129"></a>00129 ~tiff_reader() { TIFFClose(_tp); } | |
164 | <a name="l00130"></a>00130 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
165 | <a name="l00131"></a>00131 <span class="keywordtype">void</span> apply(<span class="keyword">const</span> View& <a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">view</a>) { | |
166 | <a name="l00132"></a>00132 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> bps,photometric; | |
167 | <a name="l00133"></a>00133 point2<std::ptrdiff_t> dims=get_dimensions(); | |
168 | <a name="l00134"></a>00134 io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps)!=1); | |
169 | <a name="l00135"></a>00135 io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric)!=1); | |
170 | <a name="l00136"></a>00136 io_error_if(dims!=view.dimensions(), | |
171 | <a name="l00137"></a>00137 <span class="stringliteral">"tiff_read_view: input view size does not match TIFF file size"</span>); | |
172 | <a name="l00138"></a>00138 io_error_if(tiff_read_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
173 | <a name="l00139"></a>00139 <span class="keyword">typename</span> color_space_type<View>::type>::bit_depth!=bps || | |
174 | <a name="l00140"></a>00140 tiff_read_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
175 | <a name="l00141"></a>00141 <span class="keyword">typename</span> color_space_type<View>::type>::color_type!=photometric, | |
176 | <a name="l00142"></a>00142 <span class="stringliteral">"tiff_read_view: input view type is incompatible with the image type"</span>); | |
177 | <a name="l00143"></a>00143 std::size_t element_size=<span class="keyword">sizeof</span>(pixel<typename channel_type<View>::type, | |
178 | <a name="l00144"></a>00144 layout<typename color_space_type<View>::type> >); | |
179 | <a name="l00145"></a>00145 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
180 | <a name="l00146"></a>00146 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
181 | <a name="l00147"></a>00147 std::vector<pixel<typename channel_type<View>::type, | |
182 | <a name="l00148"></a>00148 layout<typename color_space_type<View>::type> > > row(size_to_allocate); | |
183 | <a name="l00149"></a>00149 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
184 | <a name="l00150"></a>00150 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
185 | <a name="l00151"></a>00151 <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>(row.begin(),row.begin()+view.width(),view.row_begin(y)); | |
186 | <a name="l00152"></a>00152 } | |
187 | <a name="l00153"></a>00153 } | |
188 | <a name="l00154"></a>00154 point2<std::ptrdiff_t> get_dimensions() { | |
189 | <a name="l00155"></a>00155 <span class="keywordtype">int</span> w,h; | |
190 | <a name="l00156"></a>00156 io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGEWIDTH, &w)!=1); | |
191 | <a name="l00157"></a>00157 io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGELENGTH,&h)!=1); | |
192 | <a name="l00158"></a>00158 <span class="keywordflow">return</span> point2<std::ptrdiff_t>(w,h); | |
193 | <a name="l00159"></a>00159 } | |
194 | <a name="l00160"></a>00160 | |
195 | <a name="l00161"></a>00161 <span class="keyword">template</span> <<span class="keyword">typename</span> Image> | |
196 | <a name="l00162"></a>00162 <span class="keywordtype">void</span> read_image(Image& im) { | |
197 | <a name="l00163"></a>00163 im.recreate(get_dimensions()); | |
198 | <a name="l00164"></a>00164 apply(<a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">view</a>(im)); | |
199 | <a name="l00165"></a>00165 } | |
200 | <a name="l00166"></a>00166 }; | |
201 | <a name="l00167"></a>00167 | |
202 | <a name="l00168"></a>00168 <span class="comment">// This code will be simplified...</span> | |
203 | <a name="l00169"></a>00169 <span class="keyword">template</span> <<span class="keyword">typename</span> CC> | |
204 | <a name="l00170"></a>00170 <span class="keyword">class </span>tiff_reader_color_convert : <span class="keyword">public</span> tiff_reader { | |
205 | <a name="l00171"></a>00171 <span class="keyword">private</span>: | |
206 | <a name="l00172"></a>00172 CC _cc; | |
207 | <a name="l00173"></a>00173 <span class="keyword">public</span>: | |
208 | <a name="l00174"></a>00174 tiff_reader_color_convert(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) : | |
209 | <a name="l00175"></a>00175 tiff_reader(filename) {} | |
210 | <a name="l00176"></a>00176 tiff_reader_color_convert(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,CC cc_in) : | |
211 | <a name="l00177"></a>00177 tiff_reader(filename),_cc(cc_in) {} | |
212 | <a name="l00178"></a>00178 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
213 | <a name="l00179"></a>00179 <span class="keywordtype">void</span> apply(<span class="keyword">const</span> View& view) { | |
214 | <a name="l00180"></a>00180 point2<std::ptrdiff_t> dims=get_dimensions(); | |
215 | <a name="l00181"></a>00181 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> bps,photometric; | |
216 | <a name="l00182"></a>00182 io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps)!=1); | |
217 | <a name="l00183"></a>00183 io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric)!=1); | |
218 | <a name="l00184"></a>00184 io_error_if(dims!=view.dimensions(), | |
219 | <a name="l00185"></a>00185 <span class="stringliteral">"tiff_reader_color_convert::apply(): input view size does not match TIFF file size"</span>); | |
220 | <a name="l00186"></a>00186 <span class="keywordflow">switch</span> (photometric) { | |
221 | <a name="l00187"></a>00187 <span class="keywordflow">case</span> PHOTOMETRIC_MINISBLACK: { | |
222 | <a name="l00188"></a>00188 <span class="keywordflow">switch</span> (bps) { | |
223 | <a name="l00189"></a>00189 <span class="keywordflow">case</span> 8: { | |
224 | <a name="l00190"></a>00190 std::size_t element_size=<span class="keyword">sizeof</span>(gray8_pixel_t); | |
225 | <a name="l00191"></a>00191 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
226 | <a name="l00192"></a>00192 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
227 | <a name="l00193"></a>00193 std::vector<gray8_pixel_t> row(size_to_allocate); | |
228 | <a name="l00194"></a>00194 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
229 | <a name="l00195"></a>00195 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
230 | <a name="l00196"></a>00196 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y), | |
231 | <a name="l00197"></a>00197 color_convert_deref_fn<gray8_ref_t,typename View::value_type,CC>(_cc)); | |
232 | <a name="l00198"></a>00198 } | |
233 | <a name="l00199"></a>00199 <span class="keywordflow">break</span>; | |
234 | <a name="l00200"></a>00200 } | |
235 | <a name="l00201"></a>00201 <span class="keywordflow">case</span> 16: { | |
236 | <a name="l00202"></a>00202 std::size_t element_size=<span class="keyword">sizeof</span>(gray16_pixel_t); | |
237 | <a name="l00203"></a>00203 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
238 | <a name="l00204"></a>00204 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
239 | <a name="l00205"></a>00205 std::vector<gray16_pixel_t> row(size_to_allocate); | |
240 | <a name="l00206"></a>00206 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
241 | <a name="l00207"></a>00207 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
242 | <a name="l00208"></a>00208 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y), | |
243 | <a name="l00209"></a>00209 color_convert_deref_fn<gray16_ref_t,typename View::value_type,CC>(_cc)); | |
244 | <a name="l00210"></a>00210 } | |
245 | <a name="l00211"></a>00211 <span class="keywordflow">break</span>; | |
246 | <a name="l00212"></a>00212 } | |
247 | <a name="l00213"></a>00213 <span class="keywordflow">case</span> 32: { | |
248 | <a name="l00214"></a>00214 std::size_t element_size=<span class="keyword">sizeof</span>(gray32f_pixel_t); | |
249 | <a name="l00215"></a>00215 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
250 | <a name="l00216"></a>00216 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
251 | <a name="l00217"></a>00217 std::vector<gray32f_pixel_t> row(size_to_allocate); | |
252 | <a name="l00218"></a>00218 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
253 | <a name="l00219"></a>00219 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
254 | <a name="l00220"></a>00220 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y), | |
255 | <a name="l00221"></a>00221 color_convert_deref_fn<gray32f_ref_t,typename View::value_type,CC>(_cc)); | |
256 | <a name="l00222"></a>00222 } | |
257 | <a name="l00223"></a>00223 <span class="keywordflow">break</span>; | |
258 | <a name="l00224"></a>00224 } | |
259 | <a name="l00225"></a>00225 <span class="keywordflow">default</span>: | |
260 | <a name="l00226"></a>00226 io_error(<span class="stringliteral">"tiff_reader_color_convert::apply(): unknown combination of color type and bit depth"</span>); | |
261 | <a name="l00227"></a>00227 } | |
262 | <a name="l00228"></a>00228 <span class="keywordflow">break</span>; | |
263 | <a name="l00229"></a>00229 } | |
264 | <a name="l00230"></a>00230 <span class="keywordflow">case</span> PHOTOMETRIC_RGB: { | |
265 | <a name="l00231"></a>00231 <span class="keywordflow">switch</span> (bps) { | |
266 | <a name="l00232"></a>00232 <span class="keywordflow">case</span> 8: { | |
267 | <a name="l00233"></a>00233 std::size_t element_size=<span class="keyword">sizeof</span>(rgb8_pixel_t); | |
268 | <a name="l00234"></a>00234 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
269 | <a name="l00235"></a>00235 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
270 | <a name="l00236"></a>00236 std::vector<rgb8_pixel_t> row(size_to_allocate); | |
271 | <a name="l00237"></a>00237 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
272 | <a name="l00238"></a>00238 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
273 | <a name="l00239"></a>00239 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y), | |
274 | <a name="l00240"></a>00240 color_convert_deref_fn<rgb8_ref_t,typename View::value_type,CC>(_cc)); | |
275 | <a name="l00241"></a>00241 } | |
276 | <a name="l00242"></a>00242 <span class="keywordflow">break</span>; | |
277 | <a name="l00243"></a>00243 } | |
278 | <a name="l00244"></a>00244 <span class="keywordflow">case</span> 16: { | |
279 | <a name="l00245"></a>00245 std::size_t element_size=<span class="keyword">sizeof</span>(rgb16_pixel_t); | |
280 | <a name="l00246"></a>00246 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
281 | <a name="l00247"></a>00247 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
282 | <a name="l00248"></a>00248 std::vector<rgb16_pixel_t> row(size_to_allocate); | |
283 | <a name="l00249"></a>00249 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
284 | <a name="l00250"></a>00250 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
285 | <a name="l00251"></a>00251 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y), | |
286 | <a name="l00252"></a>00252 color_convert_deref_fn<rgb16_ref_t,typename View::value_type,CC>(_cc)); | |
287 | <a name="l00253"></a>00253 } | |
288 | <a name="l00254"></a>00254 <span class="keywordflow">break</span>; | |
289 | <a name="l00255"></a>00255 } | |
290 | <a name="l00256"></a>00256 <span class="keywordflow">case</span> 32: { | |
291 | <a name="l00257"></a>00257 std::size_t element_size=<span class="keyword">sizeof</span>(rgb32f_pixel_t); | |
292 | <a name="l00258"></a>00258 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), | |
293 | <a name="l00259"></a>00259 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); | |
294 | <a name="l00260"></a>00260 std::vector<rgb32f_pixel_t> row(size_to_allocate); | |
295 | <a name="l00261"></a>00261 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
296 | <a name="l00262"></a>00262 io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1); | |
297 | <a name="l00263"></a>00263 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y), | |
298 | <a name="l00264"></a>00264 color_convert_deref_fn<rgb32f_ref_t,typename View::value_type,CC>(_cc)); | |
299 | <a name="l00265"></a>00265 } | |
300 | <a name="l00266"></a>00266 <span class="keywordflow">break</span>; | |
301 | <a name="l00267"></a>00267 } | |
302 | <a name="l00268"></a>00268 <span class="keywordflow">default</span>: | |
303 | <a name="l00269"></a>00269 io_error(<span class="stringliteral">"tiff_reader_color_convert::apply(): unknown combination of color type and bit depth"</span>); | |
304 | <a name="l00270"></a>00270 } | |
305 | <a name="l00271"></a>00271 <span class="keywordflow">break</span>; | |
306 | <a name="l00272"></a>00272 } | |
307 | <a name="l00273"></a>00273 <span class="keywordflow">default</span>: { | |
308 | <a name="l00274"></a>00274 <span class="comment">// reads an image in incompatible format via TIFFReadRGBAImage</span> | |
309 | <a name="l00275"></a>00275 rgba8_image_t rgbaImg(dims); | |
310 | <a name="l00276"></a>00276 io_error_if(!TIFFReadRGBAImage(_tp, dims.x, dims.y, (uint32*)&<a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">gil::view</a>(rgbaImg)(0,0), 0), | |
311 | <a name="l00277"></a>00277 <span class="stringliteral">"tiff_reader_color_convert::unsupported image format"</span>); | |
312 | <a name="l00278"></a>00278 copy_and_convert_pixels(flipped_up_down_view(<a class="code" href="g_i_l_0135.html#g9e185237819e788838a0d337d21ab722" title="Returns the constant-pixel view of any image. The returned view is any view.">const_view</a>(rgbaImg)), view, _cc); | |
313 | <a name="l00279"></a>00279 } | |
314 | <a name="l00280"></a>00280 } | |
315 | <a name="l00281"></a>00281 } | |
316 | <a name="l00282"></a>00282 <span class="keyword">template</span> <<span class="keyword">typename</span> Image> | |
317 | <a name="l00283"></a>00283 <span class="keywordtype">void</span> read_image(Image& im) { | |
318 | <a name="l00284"></a>00284 im.recreate(get_dimensions()); | |
319 | <a name="l00285"></a>00285 apply(<a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">view</a>(im)); | |
320 | <a name="l00286"></a>00286 } | |
321 | <a name="l00287"></a>00287 }; | |
322 | <a name="l00288"></a>00288 | |
323 | <a name="l00289"></a>00289 <span class="keyword">class </span>tiff_writer { | |
324 | <a name="l00290"></a>00290 <span class="keyword">protected</span>: | |
325 | <a name="l00291"></a>00291 TIFF* _tp; | |
326 | <a name="l00292"></a>00292 <span class="keyword">public</span>: | |
327 | <a name="l00293"></a>00293 tiff_writer(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename) { | |
328 | <a name="l00294"></a>00294 io_error_if((_tp=TIFFOpen(filename,<span class="stringliteral">"w"</span>))==NULL, | |
329 | <a name="l00295"></a>00295 <span class="stringliteral">"tiff_writer: fail to open file"</span>); | |
330 | <a name="l00296"></a>00296 } | |
331 | <a name="l00297"></a>00297 ~tiff_writer() {TIFFClose(_tp);} | |
332 | <a name="l00298"></a>00298 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
333 | <a name="l00299"></a>00299 <span class="keywordtype">void</span> apply(<span class="keyword">const</span> View& view) { | |
334 | <a name="l00300"></a>00300 io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGELENGTH, view.height())!=1); | |
335 | <a name="l00301"></a>00301 io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGEWIDTH, view.width())!=1); | |
336 | <a name="l00302"></a>00302 io_error_if(TIFFSetField(_tp,TIFFTAG_PHOTOMETRIC, tiff_write_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
337 | <a name="l00303"></a>00303 <span class="keyword">typename</span> color_space_type<View>::type>::color_type)!=1); | |
338 | <a name="l00304"></a>00304 io_error_if(TIFFSetField(_tp,TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE)!=1); | |
339 | <a name="l00305"></a>00305 io_error_if(TIFFSetField(_tp,TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)!=1); | |
340 | <a name="l00306"></a>00306 io_error_if(TIFFSetField(_tp,TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT)!=1); | |
341 | <a name="l00307"></a>00307 io_error_if(TIFFSetField(_tp,TIFFTAG_SAMPLESPERPIXEL,num_channels<View>::value)!=1); | |
342 | <a name="l00308"></a>00308 io_error_if(TIFFSetField(_tp,TIFFTAG_BITSPERSAMPLE, tiff_write_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
343 | <a name="l00309"></a>00309 <span class="keyword">typename</span> color_space_type<View>::type>::bit_depth)!=1); | |
344 | <a name="l00310"></a>00310 io_error_if(TIFFSetField(_tp,TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(_tp, 0))!=1); | |
345 | <a name="l00311"></a>00311 std::vector<pixel<typename channel_type<View>::type, | |
346 | <a name="l00312"></a>00312 layout<typename color_space_type<View>::type> > > row(view.width()); | |
347 | <a name="l00313"></a>00313 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y<view.height();++y) { | |
348 | <a name="l00314"></a>00314 <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>(view.row_begin(y),view.row_end(y),row.begin()); | |
349 | <a name="l00315"></a>00315 io_error_if(TIFFWriteScanline(_tp,&row.front(),y,0)!=1, | |
350 | <a name="l00316"></a>00316 <span class="stringliteral">"tiff_write_view: fail to write file"</span>); | |
351 | <a name="l00317"></a>00317 } | |
352 | <a name="l00318"></a>00318 } | |
353 | <a name="l00319"></a>00319 }; | |
354 | <a name="l00320"></a>00320 | |
355 | <a name="l00321"></a>00321 } <span class="comment">// namespace detail</span> | |
356 | <a name="l00322"></a>00322 | |
357 | <a name="l00325"></a>00325 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
358 | <a name="l00326"></a><a class="code" href="g_i_l_0623.html">00326</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0623.html" title="Determines whether the given view type is supported for reading.">tiff_read_support</a> { | |
359 | <a name="l00327"></a>00327 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported= | |
360 | <a name="l00328"></a>00328 (detail::tiff_read_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
361 | <a name="l00329"></a>00329 <span class="keyword">typename</span> color_space_type<View>::type>::is_supported)); | |
362 | <a name="l00330"></a>00330 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth= | |
363 | <a name="l00331"></a>00331 (detail::tiff_read_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
364 | <a name="l00332"></a>00332 <span class="keyword">typename</span> color_space_type<View>::type>::bit_depth)); | |
365 | <a name="l00333"></a>00333 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type= | |
366 | <a name="l00334"></a>00334 (detail::tiff_read_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
367 | <a name="l00335"></a>00335 <span class="keyword">typename</span> color_space_type<View>::type>::color_type)); | |
368 | <a name="l00336"></a>00336 }; | |
369 | <a name="l00337"></a>00337 | |
370 | <a name="l00341"></a><a class="code" href="g_i_l_0216.html#g2ba83bb2df815c50bab5526c5b411112">00341</a> <span class="keyword">inline</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2<std::ptrdiff_t></a> <a class="code" href="g_i_l_0216.html#g8b31d48262e61c900009ac6bd9e86bcd" title="Returns the width and height of the TIFF file at the specified location. Throws std::ios_base::failu...">tiff_read_dimensions</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) { | |
371 | <a name="l00342"></a>00342 detail::tiff_reader m(filename); | |
372 | <a name="l00343"></a>00343 <span class="keywordflow">return</span> m.get_dimensions(); | |
373 | <a name="l00344"></a>00344 } | |
374 | <a name="l00345"></a>00345 | |
375 | <a name="l00349"></a><a class="code" href="g_i_l_0216.html#g8b31d48262e61c900009ac6bd9e86bcd">00349</a> <span class="keyword">inline</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2<std::ptrdiff_t></a> <a class="code" href="g_i_l_0216.html#g8b31d48262e61c900009ac6bd9e86bcd" title="Returns the width and height of the TIFF file at the specified location. Throws std::ios_base::failu...">tiff_read_dimensions</a>(<span class="keyword">const</span> std::string& filename) { | |
376 | <a name="l00350"></a>00350 <span class="keywordflow">return</span> <a class="code" href="g_i_l_0216.html#g8b31d48262e61c900009ac6bd9e86bcd" title="Returns the width and height of the TIFF file at the specified location. Throws std::ios_base::failu...">tiff_read_dimensions</a>(filename.c_str()); | |
377 | <a name="l00351"></a>00351 } | |
378 | <a name="l00352"></a>00352 | |
379 | <a name="l00358"></a>00358 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
380 | <a name="l00359"></a><a class="code" href="g_i_l_0216.html#g7fd10d03f899b14858eeb7b9c0c89f37">00359</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g4a2d3d9b5b0f3d963e5a8bec3c42cd91" title="Loads the image specified by the given tiff image file name into the given view.">tiff_read_view</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,<span class="keyword">const</span> View& view) { | |
381 | <a name="l00360"></a>00360 BOOST_STATIC_ASSERT(<a class="code" href="g_i_l_0623.html" title="Determines whether the given view type is supported for reading.">tiff_read_support<View>::is_supported</a>); | |
382 | <a name="l00361"></a>00361 detail::tiff_reader m(filename); | |
383 | <a name="l00362"></a>00362 m.apply(view); | |
384 | <a name="l00363"></a>00363 } | |
385 | <a name="l00364"></a>00364 | |
386 | <a name="l00367"></a>00367 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
387 | <a name="l00368"></a><a class="code" href="g_i_l_0216.html#g4a2d3d9b5b0f3d963e5a8bec3c42cd91">00368</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g4a2d3d9b5b0f3d963e5a8bec3c42cd91" title="Loads the image specified by the given tiff image file name into the given view.">tiff_read_view</a>(<span class="keyword">const</span> std::string& filename,<span class="keyword">const</span> View& view) { | |
388 | <a name="l00369"></a>00369 <a class="code" href="g_i_l_0216.html#g4a2d3d9b5b0f3d963e5a8bec3c42cd91" title="Loads the image specified by the given tiff image file name into the given view.">tiff_read_view</a>(filename.c_str(),view); | |
389 | <a name="l00370"></a>00370 } | |
390 | <a name="l00371"></a>00371 | |
391 | <a name="l00377"></a>00377 <span class="keyword">template</span> <<span class="keyword">typename</span> Image> | |
392 | <a name="l00378"></a><a class="code" href="g_i_l_0216.html#g7de2814cc2089525400fe71ce00e78f9">00378</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g14ff6b4a743878cac2b32fdaedd5e705" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_image</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,Image& im) { | |
393 | <a name="l00379"></a>00379 BOOST_STATIC_ASSERT(<a class="code" href="g_i_l_0623.html" title="Determines whether the given view type is supported for reading.">tiff_read_support<typename Image::view_t>::is_supported</a>); | |
394 | <a name="l00380"></a>00380 detail::tiff_reader m(filename); | |
395 | <a name="l00381"></a>00381 m.read_image(im); | |
396 | <a name="l00382"></a>00382 } | |
397 | <a name="l00383"></a>00383 | |
398 | <a name="l00386"></a>00386 <span class="keyword">template</span> <<span class="keyword">typename</span> Image> | |
399 | <a name="l00387"></a><a class="code" href="g_i_l_0216.html#g14ff6b4a743878cac2b32fdaedd5e705">00387</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g14ff6b4a743878cac2b32fdaedd5e705" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_image</a>(<span class="keyword">const</span> std::string& filename,Image& im) { | |
400 | <a name="l00388"></a>00388 <a class="code" href="g_i_l_0216.html#g14ff6b4a743878cac2b32fdaedd5e705" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_image</a>(filename.c_str(),im); | |
401 | <a name="l00389"></a>00389 } | |
402 | <a name="l00390"></a>00390 | |
403 | <a name="l00394"></a>00394 <span class="keyword">template</span> <<span class="keyword">typename</span> View,<span class="keyword">typename</span> CC> | |
404 | <a name="l00395"></a><a class="code" href="g_i_l_0216.html#g6d0a5976a464ffecb65f576ea6fcbf0d">00395</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5" title="Loads and color-converts the image specified by the given tiff image file name into...">tiff_read_and_convert_view</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,<span class="keyword">const</span> View& view,CC cc) { | |
405 | <a name="l00396"></a>00396 detail::tiff_reader_color_convert<CC> m(filename,cc); | |
406 | <a name="l00397"></a>00397 m.apply(view); | |
407 | <a name="l00398"></a>00398 } | |
408 | <a name="l00399"></a>00399 | |
409 | <a name="l00403"></a>00403 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
410 | <a name="l00404"></a><a class="code" href="g_i_l_0216.html#gfbd25171c6709b26a918347c79123dec">00404</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5" title="Loads and color-converts the image specified by the given tiff image file name into...">tiff_read_and_convert_view</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,<span class="keyword">const</span> View& view) { | |
411 | <a name="l00405"></a>00405 detail::tiff_reader_color_convert<default_color_converter> m(filename,<a class="code" href="g_i_l_0452.html" title="class for color-converting one pixel to another">default_color_converter</a>()); | |
412 | <a name="l00406"></a>00406 m.apply(view); | |
413 | <a name="l00407"></a>00407 } | |
414 | <a name="l00408"></a>00408 | |
415 | <a name="l00411"></a>00411 <span class="keyword">template</span> <<span class="keyword">typename</span> View,<span class="keyword">typename</span> CC> | |
416 | <a name="l00412"></a><a class="code" href="g_i_l_0216.html#ga6c1a60f6eb8fcf72e5d13017e7cb635">00412</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5" title="Loads and color-converts the image specified by the given tiff image file name into...">tiff_read_and_convert_view</a>(<span class="keyword">const</span> std::string& filename,<span class="keyword">const</span> View& view,CC cc) { | |
417 | <a name="l00413"></a>00413 <a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5" title="Loads and color-converts the image specified by the given tiff image file name into...">tiff_read_and_convert_view</a>(filename.c_str(),view,cc); | |
418 | <a name="l00414"></a>00414 } | |
419 | <a name="l00415"></a>00415 | |
420 | <a name="l00418"></a>00418 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
421 | <a name="l00419"></a><a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5">00419</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5" title="Loads and color-converts the image specified by the given tiff image file name into...">tiff_read_and_convert_view</a>(<span class="keyword">const</span> std::string& filename,<span class="keyword">const</span> View& view) { | |
422 | <a name="l00420"></a>00420 <a class="code" href="g_i_l_0216.html#g70a389ee105e3e4d68c6b6b5960be3b5" title="Loads and color-converts the image specified by the given tiff image file name into...">tiff_read_and_convert_view</a>(filename.c_str(),view); | |
423 | <a name="l00421"></a>00421 } | |
424 | <a name="l00422"></a>00422 | |
425 | <a name="l00426"></a>00426 <span class="keyword">template</span> <<span class="keyword">typename</span> Image,<span class="keyword">typename</span> CC> | |
426 | <a name="l00427"></a><a class="code" href="g_i_l_0216.html#g7c4b48141392f077294832fc454a1305">00427</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_and_convert_image</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,Image& im,CC cc) { | |
427 | <a name="l00428"></a>00428 detail::tiff_reader_color_convert<CC> m(filename,cc); | |
428 | <a name="l00429"></a>00429 m.read_image(im); | |
429 | <a name="l00430"></a>00430 } | |
430 | <a name="l00431"></a>00431 | |
431 | <a name="l00435"></a>00435 <span class="keyword">template</span> <<span class="keyword">typename</span> Image> | |
432 | <a name="l00436"></a><a class="code" href="g_i_l_0216.html#g0d7443b89bad3aea2c626b3c0bc14f36">00436</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_and_convert_image</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,Image& im) { | |
433 | <a name="l00437"></a>00437 detail::tiff_reader_color_convert<default_color_converter> m(filename,<a class="code" href="g_i_l_0452.html" title="class for color-converting one pixel to another">default_color_converter</a>()); | |
434 | <a name="l00438"></a>00438 m.read_image(im); | |
435 | <a name="l00439"></a>00439 } | |
436 | <a name="l00440"></a>00440 | |
437 | <a name="l00443"></a>00443 <span class="keyword">template</span> <<span class="keyword">typename</span> Image,<span class="keyword">typename</span> CC> | |
438 | <a name="l00444"></a><a class="code" href="g_i_l_0216.html#g7138a8a01225d3fec81ba55dda09b1ba">00444</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_and_convert_image</a>(<span class="keyword">const</span> std::string& filename,Image& im,CC cc) { | |
439 | <a name="l00445"></a>00445 <a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_and_convert_image</a>(filename.c_str(),im,cc); | |
440 | <a name="l00446"></a>00446 } | |
441 | <a name="l00447"></a>00447 | |
442 | <a name="l00450"></a>00450 <span class="keyword">template</span> <<span class="keyword">typename</span> Image> | |
443 | <a name="l00451"></a><a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6">00451</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_and_convert_image</a>(<span class="keyword">const</span> std::string& filename,Image& im) { | |
444 | <a name="l00452"></a>00452 <a class="code" href="g_i_l_0216.html#gde7bb58e80854798d895fef8406a6ad6" title="Allocates a new image whose dimensions are determined by the given tiff image file...">tiff_read_and_convert_image</a>(filename.c_str(),im); | |
445 | <a name="l00453"></a>00453 } | |
446 | <a name="l00454"></a>00454 | |
447 | <a name="l00457"></a>00457 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
448 | <a name="l00458"></a><a class="code" href="g_i_l_0625.html">00458</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0625.html" title="Determines whether the given view type is supported for writing.">tiff_write_support</a> { | |
449 | <a name="l00459"></a>00459 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported= | |
450 | <a name="l00460"></a>00460 (detail::tiff_write_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
451 | <a name="l00461"></a>00461 <span class="keyword">typename</span> color_space_type<View>::type>::is_supported)); | |
452 | <a name="l00462"></a>00462 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth= | |
453 | <a name="l00463"></a>00463 (detail::tiff_write_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
454 | <a name="l00464"></a>00464 <span class="keyword">typename</span> color_space_type<View>::type>::bit_depth)); | |
455 | <a name="l00465"></a>00465 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type= | |
456 | <a name="l00466"></a>00466 (detail::tiff_write_support_private<<span class="keyword">typename</span> channel_type<View>::type, | |
457 | <a name="l00467"></a>00467 <span class="keyword">typename</span> color_space_type<View>::type>::color_type)); | |
458 | <a name="l00468"></a>00468 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, value=is_supported); | |
459 | <a name="l00469"></a>00469 }; | |
460 | <a name="l00470"></a>00470 | |
461 | <a name="l00475"></a>00475 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
462 | <a name="l00476"></a><a class="code" href="g_i_l_0216.html#g1ef8f86c35347f6f0a5c3662fa1dca81">00476</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g99ce921bc92a5bbcf2145d3387e5e323" title="Saves the view to a tiff file specified by the given tiff image file name.">tiff_write_view</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,<span class="keyword">const</span> View& view) { | |
463 | <a name="l00477"></a>00477 BOOST_STATIC_ASSERT(<a class="code" href="g_i_l_0625.html" title="Determines whether the given view type is supported for writing.">tiff_write_support<View>::is_supported</a>); | |
464 | <a name="l00478"></a>00478 detail::tiff_writer m(filename); | |
465 | <a name="l00479"></a>00479 m.apply(view); | |
466 | <a name="l00480"></a>00480 } | |
467 | <a name="l00481"></a>00481 | |
468 | <a name="l00484"></a>00484 <span class="keyword">template</span> <<span class="keyword">typename</span> View> | |
469 | <a name="l00485"></a><a class="code" href="g_i_l_0216.html#g99ce921bc92a5bbcf2145d3387e5e323">00485</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0216.html#g99ce921bc92a5bbcf2145d3387e5e323" title="Saves the view to a tiff file specified by the given tiff image file name.">tiff_write_view</a>(<span class="keyword">const</span> std::string& filename,<span class="keyword">const</span> View& view) { | |
470 | <a name="l00486"></a>00486 <a class="code" href="g_i_l_0216.html#g99ce921bc92a5bbcf2145d3387e5e323" title="Saves the view to a tiff file specified by the given tiff image file name.">tiff_write_view</a>(filename.c_str(),view); | |
471 | <a name="l00487"></a>00487 } | |
472 | <a name="l00488"></a>00488 | |
473 | <a name="l00489"></a>00489 } } <span class="comment">// namespace boost::gil</span> | |
474 | <a name="l00490"></a>00490 | |
475 | <a name="l00491"></a>00491 <span class="preprocessor">#endif</span> | |
476 | </pre></div></div> | |
477 | <hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:15 2009 for Generic Image Library by | |
478 | <a href="http://www.doxygen.org/index.html"> | |
479 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> | |
480 | </body> | |
481 | </html> |