blob: 56270bfb5144b32fbb583f651b8d0e513f27ff67 [file] [log] [blame]
<!-- Copyright 2008 Lubomir Bourdev and Hailin Jin
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
-->
<!--
Copyright 2005-2007 Adobe Systems Incorporated
Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
or a copy at http://stlab.adobe.com/licenses.html)
Some files are held under additional license.
Please see "http://stlab.adobe.com/licenses.html" for more information.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<TITLE>Generic Image Library: tiff_io.hpp Source File</TITLE>
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/>
<LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr>
<td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'>
<div class="qindex"><a class="qindex" href="index.html">Modules</a>
| <a class="qindex" href="classes.html">Alphabetical List</a>
| <a class="qindex" href="annotated.html">Class List</a>
| <a class="qindex" href="dirs.html">Directories</a>
| <a class="qindex" href="files.html">File List</a>
| <a class="qindex" href="../index.html">GIL Home Page</a>
</div>
<!-- End Header -->
<!-- Generated by Doxygen 1.5.6 -->
<div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0079.html">gil</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0078.html">extension</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0077.html">io</a>
</div>
<div class="contents">
<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>
<a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2007 Adobe Systems Incorporated</span>
<a name="l00003"></a>00003 <span class="comment"> </span>
<a name="l00004"></a>00004 <span class="comment"> Use, modification and distribution are subject to the Boost Software License,</span>
<a name="l00005"></a>00005 <span class="comment"> Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
<a name="l00006"></a>00006 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt).</span>
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment"> See http://opensource.adobe.com/gil for most recent version including documentation.</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a>00010
<a name="l00011"></a>00011 <span class="comment">/*************************************************************************************************/</span>
<a name="l00012"></a>00012
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef GIL_TIFF_IO_H</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_TIFF_IO_H</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;boost/static_assert.hpp&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;tiffio.h&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "../../gil_all.hpp"</span>
<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>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="keyword">namespace </span>detail {
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Channel,<span class="keyword">typename</span> ColorSpace&gt;
<a name="l00036"></a>00036 <span class="keyword">struct </span>tiff_read_support_private {
<a name="l00037"></a>00037 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">false</span>);
<a name="l00038"></a>00038 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=0);
<a name="l00039"></a>00039 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=0);
<a name="l00040"></a>00040 };
<a name="l00041"></a>00041 <span class="keyword">template</span> &lt;&gt;
<a name="l00042"></a>00042 <span class="keyword">struct </span>tiff_read_support_private&lt;bits8,gray_t&gt; {
<a name="l00043"></a>00043 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00044"></a>00044 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8);
<a name="l00045"></a>00045 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK);
<a name="l00046"></a>00046 };
<a name="l00047"></a>00047 <span class="keyword">template</span> &lt;&gt;
<a name="l00048"></a>00048 <span class="keyword">struct </span>tiff_read_support_private&lt;bits8,rgb_t&gt; {
<a name="l00049"></a>00049 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00050"></a>00050 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8);
<a name="l00051"></a>00051 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB);
<a name="l00052"></a>00052 };
<a name="l00053"></a>00053 <span class="keyword">template</span> &lt;&gt;
<a name="l00054"></a>00054 <span class="keyword">struct </span>tiff_read_support_private&lt;bits16,gray_t&gt; {
<a name="l00055"></a>00055 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00056"></a>00056 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16);
<a name="l00057"></a>00057 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK);
<a name="l00058"></a>00058 };
<a name="l00059"></a>00059 <span class="keyword">template</span> &lt;&gt;
<a name="l00060"></a>00060 <span class="keyword">struct </span>tiff_read_support_private&lt;bits16,rgb_t&gt; {
<a name="l00061"></a>00061 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00062"></a>00062 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16);
<a name="l00063"></a>00063 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB);
<a name="l00064"></a>00064 };
<a name="l00065"></a>00065 <span class="keyword">template</span> &lt;&gt;
<a name="l00066"></a>00066 <span class="keyword">struct </span>tiff_read_support_private&lt;bits32f,gray_t&gt; {
<a name="l00067"></a>00067 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00068"></a>00068 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32);
<a name="l00069"></a>00069 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK);
<a name="l00070"></a>00070 };
<a name="l00071"></a>00071 <span class="keyword">template</span> &lt;&gt;
<a name="l00072"></a>00072 <span class="keyword">struct </span>tiff_read_support_private&lt;bits32f,rgb_t&gt; {
<a name="l00073"></a>00073 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00074"></a>00074 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32);
<a name="l00075"></a>00075 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB);
<a name="l00076"></a>00076 };
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Channel,<span class="keyword">typename</span> ColorSpace&gt;
<a name="l00079"></a>00079 <span class="keyword">struct </span>tiff_write_support_private {
<a name="l00080"></a>00080 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">false</span>);
<a name="l00081"></a>00081 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=0);
<a name="l00082"></a>00082 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=0);
<a name="l00083"></a>00083 };
<a name="l00084"></a>00084 <span class="keyword">template</span> &lt;&gt;
<a name="l00085"></a>00085 <span class="keyword">struct </span>tiff_write_support_private&lt;bits8,gray_t&gt; {
<a name="l00086"></a>00086 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00087"></a>00087 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8);
<a name="l00088"></a>00088 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK);
<a name="l00089"></a>00089 };
<a name="l00090"></a>00090 <span class="keyword">template</span> &lt;&gt;
<a name="l00091"></a>00091 <span class="keyword">struct </span>tiff_write_support_private&lt;bits8,rgb_t&gt; {
<a name="l00092"></a>00092 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00093"></a>00093 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=8);
<a name="l00094"></a>00094 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB);
<a name="l00095"></a>00095 };
<a name="l00096"></a>00096 <span class="keyword">template</span> &lt;&gt;
<a name="l00097"></a>00097 <span class="keyword">struct </span>tiff_write_support_private&lt;bits16,gray_t&gt; {
<a name="l00098"></a>00098 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00099"></a>00099 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16);
<a name="l00100"></a>00100 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK);
<a name="l00101"></a>00101 };
<a name="l00102"></a>00102 <span class="keyword">template</span> &lt;&gt;
<a name="l00103"></a>00103 <span class="keyword">struct </span>tiff_write_support_private&lt;bits16,rgb_t&gt; {
<a name="l00104"></a>00104 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00105"></a>00105 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=16);
<a name="l00106"></a>00106 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB);
<a name="l00107"></a>00107 };
<a name="l00108"></a>00108 <span class="keyword">template</span> &lt;&gt;
<a name="l00109"></a>00109 <span class="keyword">struct </span>tiff_write_support_private&lt;bits32f,gray_t&gt; {
<a name="l00110"></a>00110 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00111"></a>00111 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32);
<a name="l00112"></a>00112 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_MINISBLACK);
<a name="l00113"></a>00113 };
<a name="l00114"></a>00114 <span class="keyword">template</span> &lt;&gt;
<a name="l00115"></a>00115 <span class="keyword">struct </span>tiff_write_support_private&lt;bits32f,rgb_t&gt; {
<a name="l00116"></a>00116 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=<span class="keyword">true</span>);
<a name="l00117"></a>00117 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=32);
<a name="l00118"></a>00118 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=PHOTOMETRIC_RGB);
<a name="l00119"></a>00119 };
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="keyword">class </span>tiff_reader {
<a name="l00122"></a>00122 <span class="keyword">protected</span>:
<a name="l00123"></a>00123 TIFF *_tp;
<a name="l00124"></a>00124 <span class="keyword">public</span>:
<a name="l00125"></a>00125 tiff_reader(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) {
<a name="l00126"></a>00126 io_error_if((_tp=TIFFOpen(filename,<span class="stringliteral">"r"</span>))==NULL,
<a name="l00127"></a>00127 <span class="stringliteral">"tiff_reader: fail to open file"</span>);
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 ~tiff_reader() { TIFFClose(_tp); }
<a name="l00130"></a>00130 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<a name="l00131"></a>00131 <span class="keywordtype">void</span> apply(<span class="keyword">const</span> View&amp; <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>) {
<a name="l00132"></a>00132 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> bps,photometric;
<a name="l00133"></a>00133 point2&lt;std::ptrdiff_t&gt; dims=get_dimensions();
<a name="l00134"></a>00134 io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&amp;bps)!=1);
<a name="l00135"></a>00135 io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&amp;photometric)!=1);
<a name="l00136"></a>00136 io_error_if(dims!=view.dimensions(),
<a name="l00137"></a>00137 <span class="stringliteral">"tiff_read_view: input view size does not match TIFF file size"</span>);
<a name="l00138"></a>00138 io_error_if(tiff_read_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00139"></a>00139 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::bit_depth!=bps ||
<a name="l00140"></a>00140 tiff_read_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00141"></a>00141 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::color_type!=photometric,
<a name="l00142"></a>00142 <span class="stringliteral">"tiff_read_view: input view type is incompatible with the image type"</span>);
<a name="l00143"></a>00143 std::size_t element_size=<span class="keyword">sizeof</span>(pixel&lt;typename channel_type&lt;View&gt;::type,
<a name="l00144"></a>00144 layout&lt;typename color_space_type&lt;View&gt;::type&gt; &gt;);
<a name="l00145"></a>00145 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00146"></a>00146 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00147"></a>00147 std::vector&lt;pixel&lt;typename channel_type&lt;View&gt;::type,
<a name="l00148"></a>00148 layout&lt;typename color_space_type&lt;View&gt;::type&gt; &gt; &gt; row(size_to_allocate);
<a name="l00149"></a>00149 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00150"></a>00150 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<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));
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 point2&lt;std::ptrdiff_t&gt; get_dimensions() {
<a name="l00155"></a>00155 <span class="keywordtype">int</span> w,h;
<a name="l00156"></a>00156 io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGEWIDTH, &amp;w)!=1);
<a name="l00157"></a>00157 io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGELENGTH,&amp;h)!=1);
<a name="l00158"></a>00158 <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(w,h);
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt;
<a name="l00162"></a>00162 <span class="keywordtype">void</span> read_image(Image&amp; im) {
<a name="l00163"></a>00163 im.recreate(get_dimensions());
<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));
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 };
<a name="l00167"></a>00167
<a name="l00168"></a>00168 <span class="comment">// This code will be simplified...</span>
<a name="l00169"></a>00169 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> CC&gt;
<a name="l00170"></a>00170 <span class="keyword">class </span>tiff_reader_color_convert : <span class="keyword">public</span> tiff_reader {
<a name="l00171"></a>00171 <span class="keyword">private</span>:
<a name="l00172"></a>00172 CC _cc;
<a name="l00173"></a>00173 <span class="keyword">public</span>:
<a name="l00174"></a>00174 tiff_reader_color_convert(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) :
<a name="l00175"></a>00175 tiff_reader(filename) {}
<a name="l00176"></a>00176 tiff_reader_color_convert(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename,CC cc_in) :
<a name="l00177"></a>00177 tiff_reader(filename),_cc(cc_in) {}
<a name="l00178"></a>00178 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<a name="l00179"></a>00179 <span class="keywordtype">void</span> apply(<span class="keyword">const</span> View&amp; view) {
<a name="l00180"></a>00180 point2&lt;std::ptrdiff_t&gt; dims=get_dimensions();
<a name="l00181"></a>00181 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> bps,photometric;
<a name="l00182"></a>00182 io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&amp;bps)!=1);
<a name="l00183"></a>00183 io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&amp;photometric)!=1);
<a name="l00184"></a>00184 io_error_if(dims!=view.dimensions(),
<a name="l00185"></a>00185 <span class="stringliteral">"tiff_reader_color_convert::apply(): input view size does not match TIFF file size"</span>);
<a name="l00186"></a>00186 <span class="keywordflow">switch</span> (photometric) {
<a name="l00187"></a>00187 <span class="keywordflow">case</span> PHOTOMETRIC_MINISBLACK: {
<a name="l00188"></a>00188 <span class="keywordflow">switch</span> (bps) {
<a name="l00189"></a>00189 <span class="keywordflow">case</span> 8: {
<a name="l00190"></a>00190 std::size_t element_size=<span class="keyword">sizeof</span>(gray8_pixel_t);
<a name="l00191"></a>00191 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00192"></a>00192 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00193"></a>00193 std::vector&lt;gray8_pixel_t&gt; row(size_to_allocate);
<a name="l00194"></a>00194 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00195"></a>00195 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<a name="l00196"></a>00196 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
<a name="l00197"></a>00197 color_convert_deref_fn&lt;gray8_ref_t,typename View::value_type,CC&gt;(_cc));
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199 <span class="keywordflow">break</span>;
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201 <span class="keywordflow">case</span> 16: {
<a name="l00202"></a>00202 std::size_t element_size=<span class="keyword">sizeof</span>(gray16_pixel_t);
<a name="l00203"></a>00203 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00204"></a>00204 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00205"></a>00205 std::vector&lt;gray16_pixel_t&gt; row(size_to_allocate);
<a name="l00206"></a>00206 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00207"></a>00207 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<a name="l00208"></a>00208 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
<a name="l00209"></a>00209 color_convert_deref_fn&lt;gray16_ref_t,typename View::value_type,CC&gt;(_cc));
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 <span class="keywordflow">break</span>;
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213 <span class="keywordflow">case</span> 32: {
<a name="l00214"></a>00214 std::size_t element_size=<span class="keyword">sizeof</span>(gray32f_pixel_t);
<a name="l00215"></a>00215 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00216"></a>00216 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00217"></a>00217 std::vector&lt;gray32f_pixel_t&gt; row(size_to_allocate);
<a name="l00218"></a>00218 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00219"></a>00219 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<a name="l00220"></a>00220 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
<a name="l00221"></a>00221 color_convert_deref_fn&lt;gray32f_ref_t,typename View::value_type,CC&gt;(_cc));
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223 <span class="keywordflow">break</span>;
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225 <span class="keywordflow">default</span>:
<a name="l00226"></a>00226 io_error(<span class="stringliteral">"tiff_reader_color_convert::apply(): unknown combination of color type and bit depth"</span>);
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 <span class="keywordflow">break</span>;
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230 <span class="keywordflow">case</span> PHOTOMETRIC_RGB: {
<a name="l00231"></a>00231 <span class="keywordflow">switch</span> (bps) {
<a name="l00232"></a>00232 <span class="keywordflow">case</span> 8: {
<a name="l00233"></a>00233 std::size_t element_size=<span class="keyword">sizeof</span>(rgb8_pixel_t);
<a name="l00234"></a>00234 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00235"></a>00235 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00236"></a>00236 std::vector&lt;rgb8_pixel_t&gt; row(size_to_allocate);
<a name="l00237"></a>00237 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00238"></a>00238 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<a name="l00239"></a>00239 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
<a name="l00240"></a>00240 color_convert_deref_fn&lt;rgb8_ref_t,typename View::value_type,CC&gt;(_cc));
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 <span class="keywordflow">break</span>;
<a name="l00243"></a>00243 }
<a name="l00244"></a>00244 <span class="keywordflow">case</span> 16: {
<a name="l00245"></a>00245 std::size_t element_size=<span class="keyword">sizeof</span>(rgb16_pixel_t);
<a name="l00246"></a>00246 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00247"></a>00247 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00248"></a>00248 std::vector&lt;rgb16_pixel_t&gt; row(size_to_allocate);
<a name="l00249"></a>00249 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00250"></a>00250 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<a name="l00251"></a>00251 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
<a name="l00252"></a>00252 color_convert_deref_fn&lt;rgb16_ref_t,typename View::value_type,CC&gt;(_cc));
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254 <span class="keywordflow">break</span>;
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256 <span class="keywordflow">case</span> 32: {
<a name="l00257"></a>00257 std::size_t element_size=<span class="keyword">sizeof</span>(rgb32f_pixel_t);
<a name="l00258"></a>00258 std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
<a name="l00259"></a>00259 (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
<a name="l00260"></a>00260 std::vector&lt;rgb32f_pixel_t&gt; row(size_to_allocate);
<a name="l00261"></a>00261 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<a name="l00262"></a>00262 io_error_if(TIFFReadScanline(_tp,&amp;row.front(), y)!=1);
<a name="l00263"></a>00263 std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
<a name="l00264"></a>00264 color_convert_deref_fn&lt;rgb32f_ref_t,typename View::value_type,CC&gt;(_cc));
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 <span class="keywordflow">break</span>;
<a name="l00267"></a>00267 }
<a name="l00268"></a>00268 <span class="keywordflow">default</span>:
<a name="l00269"></a>00269 io_error(<span class="stringliteral">"tiff_reader_color_convert::apply(): unknown combination of color type and bit depth"</span>);
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271 <span class="keywordflow">break</span>;
<a name="l00272"></a>00272 }
<a name="l00273"></a>00273 <span class="keywordflow">default</span>: {
<a name="l00274"></a>00274 <span class="comment">// reads an image in incompatible format via TIFFReadRGBAImage</span>
<a name="l00275"></a>00275 rgba8_image_t rgbaImg(dims);
<a name="l00276"></a>00276 io_error_if(!TIFFReadRGBAImage(_tp, dims.x, dims.y, (uint32*)&amp;<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),
<a name="l00277"></a>00277 <span class="stringliteral">"tiff_reader_color_convert::unsupported image format"</span>);
<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);
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 }
<a name="l00281"></a>00281 }
<a name="l00282"></a>00282 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt;
<a name="l00283"></a>00283 <span class="keywordtype">void</span> read_image(Image&amp; im) {
<a name="l00284"></a>00284 im.recreate(get_dimensions());
<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));
<a name="l00286"></a>00286 }
<a name="l00287"></a>00287 };
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <span class="keyword">class </span>tiff_writer {
<a name="l00290"></a>00290 <span class="keyword">protected</span>:
<a name="l00291"></a>00291 TIFF* _tp;
<a name="l00292"></a>00292 <span class="keyword">public</span>:
<a name="l00293"></a>00293 tiff_writer(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename) {
<a name="l00294"></a>00294 io_error_if((_tp=TIFFOpen(filename,<span class="stringliteral">"w"</span>))==NULL,
<a name="l00295"></a>00295 <span class="stringliteral">"tiff_writer: fail to open file"</span>);
<a name="l00296"></a>00296 }
<a name="l00297"></a>00297 ~tiff_writer() {TIFFClose(_tp);}
<a name="l00298"></a>00298 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<a name="l00299"></a>00299 <span class="keywordtype">void</span> apply(<span class="keyword">const</span> View&amp; view) {
<a name="l00300"></a>00300 io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGELENGTH, view.height())!=1);
<a name="l00301"></a>00301 io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGEWIDTH, view.width())!=1);
<a name="l00302"></a>00302 io_error_if(TIFFSetField(_tp,TIFFTAG_PHOTOMETRIC, tiff_write_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00303"></a>00303 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::color_type)!=1);
<a name="l00304"></a>00304 io_error_if(TIFFSetField(_tp,TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE)!=1);
<a name="l00305"></a>00305 io_error_if(TIFFSetField(_tp,TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)!=1);
<a name="l00306"></a>00306 io_error_if(TIFFSetField(_tp,TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT)!=1);
<a name="l00307"></a>00307 io_error_if(TIFFSetField(_tp,TIFFTAG_SAMPLESPERPIXEL,num_channels&lt;View&gt;::value)!=1);
<a name="l00308"></a>00308 io_error_if(TIFFSetField(_tp,TIFFTAG_BITSPERSAMPLE, tiff_write_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00309"></a>00309 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::bit_depth)!=1);
<a name="l00310"></a>00310 io_error_if(TIFFSetField(_tp,TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(_tp, 0))!=1);
<a name="l00311"></a>00311 std::vector&lt;pixel&lt;typename channel_type&lt;View&gt;::type,
<a name="l00312"></a>00312 layout&lt;typename color_space_type&lt;View&gt;::type&gt; &gt; &gt; row(view.width());
<a name="l00313"></a>00313 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y=0;y&lt;view.height();++y) {
<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());
<a name="l00315"></a>00315 io_error_if(TIFFWriteScanline(_tp,&amp;row.front(),y,0)!=1,
<a name="l00316"></a>00316 <span class="stringliteral">"tiff_write_view: fail to write file"</span>);
<a name="l00317"></a>00317 }
<a name="l00318"></a>00318 }
<a name="l00319"></a>00319 };
<a name="l00320"></a>00320
<a name="l00321"></a>00321 } <span class="comment">// namespace detail</span>
<a name="l00322"></a>00322
<a name="l00325"></a>00325 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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> {
<a name="l00327"></a>00327 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=
<a name="l00328"></a>00328 (detail::tiff_read_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00329"></a>00329 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::is_supported));
<a name="l00330"></a>00330 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=
<a name="l00331"></a>00331 (detail::tiff_read_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00332"></a>00332 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::bit_depth));
<a name="l00333"></a>00333 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=
<a name="l00334"></a>00334 (detail::tiff_read_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00335"></a>00335 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::color_type));
<a name="l00336"></a>00336 };
<a name="l00337"></a>00337
<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&lt;std::ptrdiff_t&gt;</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) {
<a name="l00342"></a>00342 detail::tiff_reader m(filename);
<a name="l00343"></a>00343 <span class="keywordflow">return</span> m.get_dimensions();
<a name="l00344"></a>00344 }
<a name="l00345"></a>00345
<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&lt;std::ptrdiff_t&gt;</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&amp; filename) {
<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());
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352
<a name="l00358"></a>00358 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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&amp; view) {
<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&lt;View&gt;::is_supported</a>);
<a name="l00361"></a>00361 detail::tiff_reader m(filename);
<a name="l00362"></a>00362 m.apply(view);
<a name="l00363"></a>00363 }
<a name="l00364"></a>00364
<a name="l00367"></a>00367 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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&amp; filename,<span class="keyword">const</span> View&amp; view) {
<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);
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371
<a name="l00377"></a>00377 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt;
<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&amp; im) {
<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&lt;typename Image::view_t&gt;::is_supported</a>);
<a name="l00380"></a>00380 detail::tiff_reader m(filename);
<a name="l00381"></a>00381 m.read_image(im);
<a name="l00382"></a>00382 }
<a name="l00383"></a>00383
<a name="l00386"></a>00386 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt;
<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&amp; filename,Image&amp; im) {
<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);
<a name="l00389"></a>00389 }
<a name="l00390"></a>00390
<a name="l00394"></a>00394 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View,<span class="keyword">typename</span> CC&gt;
<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&amp; view,CC cc) {
<a name="l00396"></a>00396 detail::tiff_reader_color_convert&lt;CC&gt; m(filename,cc);
<a name="l00397"></a>00397 m.apply(view);
<a name="l00398"></a>00398 }
<a name="l00399"></a>00399
<a name="l00403"></a>00403 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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&amp; view) {
<a name="l00405"></a>00405 detail::tiff_reader_color_convert&lt;default_color_converter&gt; m(filename,<a class="code" href="g_i_l_0452.html" title="class for color-converting one pixel to another">default_color_converter</a>());
<a name="l00406"></a>00406 m.apply(view);
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408
<a name="l00411"></a>00411 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View,<span class="keyword">typename</span> CC&gt;
<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&amp; filename,<span class="keyword">const</span> View&amp; view,CC cc) {
<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);
<a name="l00414"></a>00414 }
<a name="l00415"></a>00415
<a name="l00418"></a>00418 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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&amp; filename,<span class="keyword">const</span> View&amp; view) {
<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);
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422
<a name="l00426"></a>00426 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image,<span class="keyword">typename</span> CC&gt;
<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&amp; im,CC cc) {
<a name="l00428"></a>00428 detail::tiff_reader_color_convert&lt;CC&gt; m(filename,cc);
<a name="l00429"></a>00429 m.read_image(im);
<a name="l00430"></a>00430 }
<a name="l00431"></a>00431
<a name="l00435"></a>00435 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt;
<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&amp; im) {
<a name="l00437"></a>00437 detail::tiff_reader_color_convert&lt;default_color_converter&gt; m(filename,<a class="code" href="g_i_l_0452.html" title="class for color-converting one pixel to another">default_color_converter</a>());
<a name="l00438"></a>00438 m.read_image(im);
<a name="l00439"></a>00439 }
<a name="l00440"></a>00440
<a name="l00443"></a>00443 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image,<span class="keyword">typename</span> CC&gt;
<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&amp; filename,Image&amp; im,CC cc) {
<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);
<a name="l00446"></a>00446 }
<a name="l00447"></a>00447
<a name="l00450"></a>00450 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt;
<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&amp; filename,Image&amp; im) {
<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);
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454
<a name="l00457"></a>00457 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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> {
<a name="l00459"></a>00459 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>,is_supported=
<a name="l00460"></a>00460 (detail::tiff_write_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00461"></a>00461 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::is_supported));
<a name="l00462"></a>00462 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,bit_depth=
<a name="l00463"></a>00463 (detail::tiff_write_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00464"></a>00464 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::bit_depth));
<a name="l00465"></a>00465 BOOST_STATIC_CONSTANT(<span class="keywordtype">int</span>,color_type=
<a name="l00466"></a>00466 (detail::tiff_write_support_private&lt;<span class="keyword">typename</span> channel_type&lt;View&gt;::type,
<a name="l00467"></a>00467 <span class="keyword">typename</span> color_space_type&lt;View&gt;::type&gt;::color_type));
<a name="l00468"></a>00468 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, value=is_supported);
<a name="l00469"></a>00469 };
<a name="l00470"></a>00470
<a name="l00475"></a>00475 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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&amp; view) {
<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&lt;View&gt;::is_supported</a>);
<a name="l00478"></a>00478 detail::tiff_writer m(filename);
<a name="l00479"></a>00479 m.apply(view);
<a name="l00480"></a>00480 }
<a name="l00481"></a>00481
<a name="l00484"></a>00484 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<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&amp; filename,<span class="keyword">const</span> View&amp; view) {
<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);
<a name="l00487"></a>00487 }
<a name="l00488"></a>00488
<a name="l00489"></a>00489 } } <span class="comment">// namespace boost::gil</span>
<a name="l00490"></a>00490
<a name="l00491"></a>00491 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:15 2009 for Generic Image Library by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>