blob: e43d15bf172981844d54ced6e3f2ad2ab51908ce [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: any_image.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_0075.html">dynamic_image</a>
</div>
<div class="contents">
<h1>any_image.hpp</h1><a href="any__image_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 <span class="comment">/*************************************************************************************************/</span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="preprocessor">#ifndef GIL_DYNAMICIMAGE_ANY_IMAGE_HPP</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define GIL_DYNAMICIMAGE_ANY_IMAGE_HPP</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="g_i_l_0004.html" title="Support for run-time instantiated image view.">any_image_view.hpp</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "../../image.hpp"</span>
<a name="l00026"></a>00026
<a name="l00027"></a>00027 <span class="comment">//#ifdef _MSC_VER</span>
<a name="l00028"></a>00028 <span class="comment">//#pragma warning(push)</span>
<a name="l00029"></a>00029 <span class="comment">//#pragma warning(disable : 4244) // conversion from 'std::ptrdiff_t' to 'int', possible loss of data. even if we static-assert the two types are the same (on visual studio 8)</span>
<a name="l00030"></a>00030 <span class="comment">//#endif</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="keyword">namespace </span>detail {
<a name="l00035"></a>00035 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">struct </span>get_view_t { <span class="keyword">typedef</span> <span class="keyword">typename</span> T::view_t type; };
<a name="l00036"></a>00036 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Images&gt; <span class="keyword">struct </span>images_get_views_t : <span class="keyword">public</span> mpl::transform&lt;Images, get_view_t&lt;mpl::_1&gt; &gt; {};
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">struct </span>get_const_view_t { <span class="keyword">typedef</span> <span class="keyword">typename</span> T::const_view_t type; };
<a name="l00039"></a>00039 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Images&gt; <span class="keyword">struct </span>images_get_const_views_t : <span class="keyword">public</span> mpl::transform&lt;Images, get_const_view_t&lt;mpl::_1&gt; &gt; {};
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="keyword">struct </span>recreate_image_fnobj {
<a name="l00042"></a>00042 <span class="keyword">typedef</span> <span class="keywordtype">void</span> result_type;
<a name="l00043"></a>00043 <span class="keyword">const</span> point2&lt;std::ptrdiff_t&gt;&amp; _dimensions;
<a name="l00044"></a>00044 <span class="keywordtype">unsigned</span> _alignment;
<a name="l00045"></a>00045
<a name="l00046"></a>00046 recreate_image_fnobj(<span class="keyword">const</span> point2&lt;std::ptrdiff_t&gt;&amp; dims, <span class="keywordtype">unsigned</span> alignment) : _dimensions(dims), _alignment(alignment) {}
<a name="l00047"></a>00047 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt; result_type operator()(Image&amp; img)<span class="keyword"> const </span>{ img.recreate(_dimensions,_alignment); }
<a name="l00048"></a>00048 };
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> AnyView&gt; <span class="comment">// Models AnyViewConcept</span>
<a name="l00051"></a>00051 <span class="keyword">struct </span>any_image_get_view {
<a name="l00052"></a>00052 <span class="keyword">typedef</span> AnyView result_type;
<a name="l00053"></a>00053 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt; result_type operator()( Image&amp; img)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> result_type(<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>(img)); }
<a name="l00054"></a>00054 };
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> AnyConstView&gt; <span class="comment">// Models AnyConstViewConcept</span>
<a name="l00057"></a>00057 <span class="keyword">struct </span>any_image_get_const_view {
<a name="l00058"></a>00058 <span class="keyword">typedef</span> AnyConstView result_type;
<a name="l00059"></a>00059 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Image&gt; result_type operator()(<span class="keyword">const</span> Image&amp; img)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> result_type(<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>(img)); }
<a name="l00060"></a>00060 };
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062
<a name="l00073"></a>00073 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ImageTypes&gt;
<a name="l00074"></a><a class="code" href="g_i_l_0018.html">00074</a> <span class="keyword">class </span><a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a> : <span class="keyword">public</span> <a class="code" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a>&lt;ImageTypes&gt; {
<a name="l00075"></a>00075 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant&lt;ImageTypes&gt;</a> <a class="code" href="g_i_l_0062.html">parent_t</a>;
<a name="l00076"></a>00076 <span class="keyword">public</span>:
<a name="l00077"></a>00077 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0020.html" title="Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCo...">any_image_view&lt;typename detail::images_get_const_views_t&lt;ImageTypes&gt;::type</a>&gt; <a class="code" href="g_i_l_0020.html" title="Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCo...">const_view_t</a>;
<a name="l00078"></a>00078 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0020.html" title="Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCo...">any_image_view&lt;typename detail::images_get_views_t&lt;ImageTypes&gt;::type</a>&gt; <a class="code" href="g_i_l_0020.html" title="Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCo...">view_t</a>;
<a name="l00079"></a>00079 <span class="keyword">typedef</span> std::ptrdiff_t x_coord_t;
<a name="l00080"></a>00080 <span class="keyword">typedef</span> std::ptrdiff_t y_coord_t;
<a name="l00081"></a>00081 <span class="keyword">typedef</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_0060.html">point_t</a>;
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>() : <a class="code" href="g_i_l_0062.html">parent_t</a>() {}
<a name="l00084"></a>00084 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">explicit</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>(<span class="keyword">const</span> T&amp; obj) : <a class="code" href="g_i_l_0062.html">parent_t</a>(obj) {}
<a name="l00085"></a>00085 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">explicit</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>(T&amp; obj, <span class="keywordtype">bool</span> do_swap) : <a class="code" href="g_i_l_0062.html">parent_t</a>(obj,do_swap) {}
<a name="l00086"></a>00086 <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>&amp; v) : <a class="code" href="g_i_l_0062.html">parent_t</a>((<span class="keyword">const</span> <a class="code" href="g_i_l_0062.html">parent_t</a>&amp;)v) {}
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>&amp; operator=(<span class="keyword">const</span> T&amp; obj) { parent_t::operator=(obj); <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
<a name="l00089"></a>00089 <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image</a>&amp; v) { parent_t::operator=((<span class="keyword">const</span> <a class="code" href="g_i_l_0062.html">parent_t</a>&amp;)v); <span class="keywordflow">return</span> *<span class="keyword">this</span>;}
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="keywordtype">void</span> recreate(<span class="keyword">const</span> <a class="code" href="g_i_l_0060.html">point_t</a>&amp; dims, <span class="keywordtype">unsigned</span> alignment=1) { <a class="code" href="group___variant.html#g3c8fd0f3dc2495060bf062428dccc505" title="Invokes a generic mutable operation (represented as a unary function object) on a...">apply_operation</a>(*<span class="keyword">this</span>,detail::recreate_image_fnobj(dims,alignment)); }
<a name="l00092"></a>00092 <span class="keywordtype">void</span> recreate(x_coord_t width, y_coord_t height, <span class="keywordtype">unsigned</span> alignment=1) { recreate(<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>(width,height),alignment); }
<a name="l00093"></a>00093
<a name="l00094"></a>00094 std::size_t <a class="code" href="g_i_l_0581.html" title="Returns the number of channels of a pixel-based GIL construct.">num_channels</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="group___variant.html#g3c8fd0f3dc2495060bf062428dccc505" title="Invokes a generic mutable operation (represented as a unary function object) on a...">apply_operation</a>(*<span class="keyword">this</span>, detail::any_type_get_num_channels()); }
<a name="l00095"></a>00095 <a class="code" href="g_i_l_0060.html">point_t</a> dimensions()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="group___variant.html#g3c8fd0f3dc2495060bf062428dccc505" title="Invokes a generic mutable operation (represented as a unary function object) on a...">apply_operation</a>(*<span class="keyword">this</span>, detail::any_type_get_dimensions()); }
<a name="l00096"></a>00096 x_coord_t width()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> dimensions().<a class="code" href="g_i_l_0060.html#9a4f74af87a76a4c3dcb729cb0e68f8d">x</a>; }
<a name="l00097"></a>00097 y_coord_t height()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> dimensions().<a class="code" href="g_i_l_0060.html#1cb2b5ea04251d543e49356ef54eb853">y</a>; }
<a name="l00098"></a>00098 };
<a name="l00099"></a>00099
<a name="l00103"></a>00103
<a name="l00105"></a>00105
<a name="l00107"></a>00107 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types&gt; GIL_FORCEINLINE <span class="comment">// Models ImageVectorConcept</span>
<a name="l00108"></a><a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e">00108</a> <span class="keyword">typename</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image&lt;Types&gt;::view_t</a> <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 class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image&lt;Types&gt;</a>&amp; anyImage) {
<a name="l00109"></a>00109 <span class="keywordflow">return</span> <a class="code" href="group___variant.html#g3dc0a90911c08815be11e1e49ec06037" title="Invokes a generic constant operation (represented as a binary function object) on...">apply_operation</a>(anyImage, detail::any_image_get_view&lt;<span class="keyword">typename</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image&lt;Types&gt;::view_t</a>&gt;());
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111
<a name="l00113"></a>00113 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types&gt; GIL_FORCEINLINE <span class="comment">// Models ImageVectorConcept</span>
<a name="l00114"></a><a class="code" href="g_i_l_0135.html#g9e185237819e788838a0d337d21ab722">00114</a> <span class="keyword">typename</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image&lt;Types&gt;::const_view_t</a> <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>(<span class="keyword">const</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image&lt;Types&gt;</a>&amp; anyImage) {
<a name="l00115"></a>00115 <span class="keywordflow">return</span> <a class="code" href="group___variant.html#g3dc0a90911c08815be11e1e49ec06037" title="Invokes a generic constant operation (represented as a binary function object) on...">apply_operation</a>(anyImage, detail::any_image_get_const_view&lt;<span class="keyword">typename</span> <a class="code" href="g_i_l_0018.html" title="Represents a run-time specified image. Note it does NOT model ImageConcept.">any_image&lt;Types&gt;::const_view_t</a>&gt;());
<a name="l00116"></a>00116 }
<a name="l00118"></a>00118
<a name="l00119"></a>00119 } } <span class="comment">// namespace boost::gil</span>
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="comment">//#ifdef _MSC_VER</span>
<a name="l00122"></a>00122 <span class="comment">//#pragma warning(pop)</span>
<a name="l00123"></a>00123 <span class="comment">//#endif</span>
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:13 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>