blob: 2454b38c655ffe847eb66c097f102fe0b50227f1 [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: channel_convert</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="contents">
<h1>channel_convert<br>
<small>
[<a class="el" href="g_i_l_0097.html">Algorithms and Utility Functions</a>]</small>
</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
Converting from one channel type to another<p>
Conversion is done as a simple linear mapping of one channel range to the other, such that the minimum/maximum value of the source maps to the minimum/maximum value of the destination. One implication of this is that the value 0 of signed channels may not be preserved!
<p>
When creating new channel models, it is often a good idea to provide specializations for the channel conversion algorithms, for example, for performance optimizations. If the new model is an integral type that can be signed, it is easier to define the conversion only for the unsigned type (<code>channel_converter_unsigned</code>) and provide specializations of <code>detail::channel_convert_to_unsigned</code> and <code>detail::channel_convert_from_unsigned</code> to convert between the signed and unsigned type.<p>
Example: <div class="fragment"><pre class="fragment"><span class="comment">// bits32f is a floating point channel with range [0.0f ... 1.0f]</span>
bits32f src_channel = channel_traits&lt;bits32f&gt;::max_value();
assert(src_channel == 1);
<span class="comment">// bits8 is 8-bit unsigned integral channel (typedef-ed from unsigned char)</span>
bits8 dst_channel = channel_convert&lt;bits8&gt;(src_channel);
assert(dst_channel == 255); <span class="comment">// max value goes to max value</span>
</pre></div>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Modules</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="g_i_l_0100.html">channel_converter_unsigned</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert one unsigned/floating point channel to another. Converts both the channel type and range. <br></td></tr>
<p>
<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="g_i_l_0408.html">channel_converter</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A unary function object converting between channel types. <a href="g_i_l_0408.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="g_i_l_0450.html">default_channel_converter</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Same as <a class="el" href="g_i_l_0408.html" title="A unary function object converting between channel types.">channel_converter</a>, except it takes the destination channel by reference, which allows us to move the templates from the class level to the method level. This is important when invoking it on heterogeneous pixels. <a href="g_i_l_0450.html#_details">More...</a><br></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="gf04e6ac30a35a1f68a8bb84730e34786"></a><!-- doxytag: member="ChannelConvertAlgorithm::channel_convert" ref="gf04e6ac30a35a1f68a8bb84730e34786" args="(SrcChannel src)" -->
template&lt;typename DstChannel, typename SrcChannel&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">channel_traits&lt; DstChannel &gt;<br>
::value_type&nbsp;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="g_i_l_0099.html#gf04e6ac30a35a1f68a8bb84730e34786">channel_convert</a> (SrcChannel src)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Converting from one channel type to another. <br></td></tr>
</table>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:16 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>