<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Gosu: Image.hpp Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.5 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <h1>Image.hpp</h1><a href="Image_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00002"></a>00002 <a name="l00003"></a>00003 <a name="l00004"></a>00004 <span class="preprocessor">#ifndef GOSU_IMAGE_HPP</span> <a name="l00005"></a>00005 <span class="preprocessor"></span><span class="preprocessor">#define GOSU_IMAGE_HPP</span> <a name="l00006"></a>00006 <span class="preprocessor"></span> <a name="l00007"></a>00007 <span class="preprocessor">#include <<a class="code" href="Fwd_8hpp.html" title="Contains declarations of all of Gosu&#39;s available classes.">Gosu/Fwd.hpp</a>></span> <a name="l00008"></a>00008 <span class="preprocessor">#include <<a class="code" href="Bitmap_8hpp.html" title="Interface of the Bitmap class.">Gosu/Bitmap.hpp</a>></span> <a name="l00009"></a>00009 <span class="preprocessor">#include <<a class="code" href="RotFlip_8hpp.html" title="Interface of the undocumented RotFlip class.">Gosu/RotFlip.hpp</a>></span> <a name="l00010"></a>00010 <span class="preprocessor">#include <boost/scoped_ptr.hpp></span> <a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="keyword">namespace </span>Gosu <a name="l00013"></a>00013 { <a name="l00015"></a><a class="code" href="classGosu_1_1Image.html">00015</a> <span class="keyword">class </span><a class="code" href="classGosu_1_1Image.html" title="Provides functionality for drawing rectangular images.">Image</a> <a name="l00016"></a>00016 { <a name="l00017"></a>00017 boost::scoped_ptr<ImageData> data; <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="keyword">public</span>: <a name="l00025"></a>00025 <a class="code" href="classGosu_1_1Image.html#b7d4a07a578bc751f446bd60954ed0cd" title="Loads an image from a given filename that can be drawn onto graphics.">Image</a>(<a class="code" href="classGosu_1_1Graphics.html" title="Serves as the target of all drawing and provides basic drawing functionality.">Graphics</a>& graphics, <span class="keyword">const</span> std::wstring& filename, <a name="l00026"></a>00026 <span class="keywordtype">bool</span> hardBorders = <span class="keyword">false</span>); <a name="l00032"></a>00032 <a class="code" href="classGosu_1_1Image.html#b7d4a07a578bc751f446bd60954ed0cd" title="Loads an image from a given filename that can be drawn onto graphics.">Image</a>(<a class="code" href="classGosu_1_1Graphics.html" title="Serves as the target of all drawing and provides basic drawing functionality.">Graphics</a>& graphics, <span class="keyword">const</span> std::wstring& filename, <span class="keywordtype">unsigned</span> srcX, <a name="l00033"></a>00033 <span class="keywordtype">unsigned</span> srcY, <span class="keywordtype">unsigned</span> srcWidth, <span class="keywordtype">unsigned</span> srcHeight, <a name="l00034"></a>00034 <span class="keywordtype">bool</span> hardBorders = <span class="keyword">false</span>); <a name="l00035"></a>00035 <a name="l00038"></a>00038 <a class="code" href="classGosu_1_1Image.html#b7d4a07a578bc751f446bd60954ed0cd" title="Loads an image from a given filename that can be drawn onto graphics.">Image</a>(<a class="code" href="classGosu_1_1Graphics.html" title="Serves as the target of all drawing and provides basic drawing functionality.">Graphics</a>& graphics, <span class="keyword">const</span> <a class="code" href="classGosu_1_1Bitmap.html" title="Rectangular area of pixels, each represented by a Color value.">Bitmap</a>& source, <a name="l00039"></a>00039 <span class="keywordtype">bool</span> hardBorders = <span class="keyword">false</span>); <a name="l00042"></a>00042 <a class="code" href="classGosu_1_1Image.html#b7d4a07a578bc751f446bd60954ed0cd" title="Loads an image from a given filename that can be drawn onto graphics.">Image</a>(<a class="code" href="classGosu_1_1Graphics.html" title="Serves as the target of all drawing and provides basic drawing functionality.">Graphics</a>& graphics, <span class="keyword">const</span> <a class="code" href="classGosu_1_1Bitmap.html" title="Rectangular area of pixels, each represented by a Color value.">Bitmap</a>& source, <span class="keywordtype">unsigned</span> srcX, <a name="l00043"></a>00043 <span class="keywordtype">unsigned</span> srcY, <span class="keywordtype">unsigned</span> srcWidth, <span class="keywordtype">unsigned</span> srcHeight, <a name="l00044"></a>00044 <span class="keywordtype">bool</span> hardBorders = <span class="keyword">false</span>); <a name="l00045"></a>00045 <a name="l00046"></a>00046 ~<a class="code" href="classGosu_1_1Image.html" title="Provides functionality for drawing rectangular images.">Image</a>(); <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="keywordtype">unsigned</span> width() <span class="keyword">const</span>; <a name="l00049"></a>00049 <span class="keywordtype">unsigned</span> height() <span class="keyword">const</span>; <a name="l00050"></a>00050 <a name="l00052"></a>00052 <span class="keywordtype">void</span> <a class="code" href="classGosu_1_1Image.html#7e6de0cae934109ba6c96434767f9540" title="Draws the image so its upper left corner is at (x; y).">draw</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <a class="code" href="namespaceGosu.html#a2fd8fe9574c0ad3fd52557cb160be49" title="Represents the Z position of something drawn with Gosu&#39;s graphics system.">ZPos</a> z, <a name="l00053"></a>00053 <span class="keywordtype">double</span> factorX = 1, <span class="keywordtype">double</span> factorY = 1, <a name="l00054"></a>00054 <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c = Colors::white, <a name="l00055"></a>00055 <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9" title="Determines the way colors are combined when one is drawn onto another.">AlphaMode</a> mode = <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9d1661cf5d3ba68fcbdca99f9dcc832e0" title="The color&#39;s channels will be interpolated.">amDefault</a>) <span class="keyword">const</span>; <a name="l00058"></a>00058 <span class="keywordtype">void</span> <a class="code" href="classGosu_1_1Image.html#6ee7e13d1def74cbf5e974fdc3b045a1" title="Like draw(), but allows to give modulation colors for all four corners.">drawMod</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <a class="code" href="namespaceGosu.html#a2fd8fe9574c0ad3fd52557cb160be49" title="Represents the Z position of something drawn with Gosu&#39;s graphics system.">ZPos</a> z, <a name="l00059"></a>00059 <span class="keywordtype">double</span> factorX, <span class="keywordtype">double</span> factorY, <a name="l00060"></a>00060 <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c1, <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c2, <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c3, <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c4, <a name="l00061"></a>00061 <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9" title="Determines the way colors are combined when one is drawn onto another.">AlphaMode</a> mode = <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9d1661cf5d3ba68fcbdca99f9dcc832e0" title="The color&#39;s channels will be interpolated.">amDefault</a>) <span class="keyword">const</span>; <a name="l00062"></a>00062 <a name="l00072"></a>00072 <span class="keywordtype">void</span> <a class="code" href="classGosu_1_1Image.html#9333d4cb15b761020a82a41357ccb674" title="Draws the image rotated by the given angle so that its rotation center is at (x;...">drawRot</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <a class="code" href="namespaceGosu.html#a2fd8fe9574c0ad3fd52557cb160be49" title="Represents the Z position of something drawn with Gosu&#39;s graphics system.">ZPos</a> z, <a name="l00073"></a>00073 <span class="keywordtype">double</span> <a class="code" href="namespaceGosu.html#f7740dec821977a37ff26a90c2e85ac7" title="Returns the angle between two points in degrees, where 0.0 means upwards.">angle</a>, <span class="keywordtype">double</span> centerX = 0.5, <span class="keywordtype">double</span> centerY = 0.5, <a name="l00074"></a>00074 <span class="keywordtype">double</span> factorX = 1, <span class="keywordtype">double</span> factorY = 1, <a name="l00075"></a>00075 <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c = Colors::white, <a name="l00076"></a>00076 <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9" title="Determines the way colors are combined when one is drawn onto another.">AlphaMode</a> mode = <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9d1661cf5d3ba68fcbdca99f9dcc832e0" title="The color&#39;s channels will be interpolated.">amDefault</a>) <span class="keyword">const</span>; <a name="l00077"></a>00077 <a name="l00078"></a>00078 <span class="preprocessor"> #ifndef SWIG</span> <a name="l00079"></a>00079 <span class="preprocessor"></span> <span class="keywordtype">void</span> drawRotFlip(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <a class="code" href="namespaceGosu.html#a2fd8fe9574c0ad3fd52557cb160be49" title="Represents the Z position of something drawn with Gosu&#39;s graphics system.">ZPos</a> z, <a name="l00080"></a>00080 RotFlip rf, <a name="l00081"></a>00081 <span class="keywordtype">double</span> factorX = 1, <span class="keywordtype">double</span> factorY = 1, <a name="l00082"></a>00082 <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c = Colors::white, <a name="l00083"></a>00083 <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9" title="Determines the way colors are combined when one is drawn onto another.">AlphaMode</a> mode = <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9d1661cf5d3ba68fcbdca99f9dcc832e0" title="The color&#39;s channels will be interpolated.">amDefault</a>) <span class="keyword">const</span>; <a name="l00084"></a>00084 <span class="keywordtype">void</span> drawRotFlipMod(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <a class="code" href="namespaceGosu.html#a2fd8fe9574c0ad3fd52557cb160be49" title="Represents the Z position of something drawn with Gosu&#39;s graphics system.">ZPos</a> z, <a name="l00085"></a>00085 RotFlip rf, <a name="l00086"></a>00086 <span class="keywordtype">double</span> factorX, <span class="keywordtype">double</span> factorY, <a name="l00087"></a>00087 <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c1, <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c2, <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c3, <a class="code" href="classGosu_1_1Color.html" title="Represents an ARGB color value with 8 bits for each channel.">Color</a> c4, <a name="l00088"></a>00088 <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9" title="Determines the way colors are combined when one is drawn onto another.">AlphaMode</a> mode = <a class="code" href="namespaceGosu.html#769656b1f560bc3d1bbdb47f8ca4eda9d1661cf5d3ba68fcbdca99f9dcc832e0" title="The color&#39;s channels will be interpolated.">amDefault</a>) <span class="keyword">const</span>; <a name="l00089"></a>00089 <a name="l00091"></a>00091 <span class="keyword">const</span> <a class="code" href="classGosu_1_1ImageData.html" title="The ImageData class is an abstract base class for drawable images.">ImageData</a>& <a class="code" href="classGosu_1_1Image.html#cbd542bae8e42ccc72442326e578c2c2" title="Provides access to the underlying image data object.">getData</a>() <span class="keyword">const</span>; <a name="l00092"></a>00092 <span class="preprocessor"> #endif</span> <a name="l00093"></a>00093 <span class="preprocessor"></span> }; <a name="l00094"></a>00094 <a name="l00103"></a>00103 <span class="keyword">template</span><<span class="keyword">typename</span> Container> <a name="l00104"></a><a class="code" href="namespaceGosu.html#b347c1ac66f7c276cc505acb62947b23">00104</a> <span class="keywordtype">void</span> <a class="code" href="namespaceGosu.html#b347c1ac66f7c276cc505acb62947b23" title="Convenience function that splits a BMP or PNG file into an area of small rectangles...">imagesFromTiledBitmap</a>(<a class="code" href="classGosu_1_1Graphics.html" title="Serves as the target of all drawing and provides basic drawing functionality.">Graphics</a>& graphics, <span class="keyword">const</span> std::wstring& filename, <a name="l00105"></a>00105 <span class="keywordtype">int</span> tileWidth, <span class="keywordtype">int</span> tileHeight, <span class="keywordtype">bool</span> hardBorders, Container& appendTo) <a name="l00106"></a>00106 { <a name="l00107"></a>00107 <a class="code" href="namespaceGosu.html#b347c1ac66f7c276cc505acb62947b23" title="Convenience function that splits a BMP or PNG file into an area of small rectangles...">imagesFromTiledBitmap</a>(graphics, quickLoadBitmap(filename), tileWidth, tileHeight, hardBorders, appendTo); <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <a name="l00118"></a>00118 <span class="keyword">template</span><<span class="keyword">typename</span> Container> <a name="l00119"></a><a class="code" href="namespaceGosu.html#823d62ccac7a28ea78ea0a987687d649">00119</a> <span class="keywordtype">void</span> <a class="code" href="namespaceGosu.html#b347c1ac66f7c276cc505acb62947b23" title="Convenience function that splits a BMP or PNG file into an area of small rectangles...">imagesFromTiledBitmap</a>(<a class="code" href="classGosu_1_1Graphics.html" title="Serves as the target of all drawing and provides basic drawing functionality.">Graphics</a>& graphics, <span class="keyword">const</span> <a class="code" href="classGosu_1_1Bitmap.html" title="Rectangular area of pixels, each represented by a Color value.">Bitmap</a>& bmp, <a name="l00120"></a>00120 <span class="keywordtype">int</span> tileWidth, <span class="keywordtype">int</span> tileHeight, <span class="keywordtype">bool</span> hardBorders, Container& appendTo) <a name="l00121"></a>00121 { <a name="l00122"></a>00122 <span class="keywordtype">int</span> tilesX, tilesY; <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="keywordflow">if</span> (tileWidth > 0) <a name="l00125"></a>00125 tilesX = bmp.<a class="code" href="classGosu_1_1Bitmap.html#eb1d21d261788c77aba770361ccdb09f">width</a>() / tileWidth; <a name="l00126"></a>00126 <span class="keywordflow">else</span> <a name="l00127"></a>00127 { <a name="l00128"></a>00128 tilesX = -tileWidth; <a name="l00129"></a>00129 tileWidth = bmp.<a class="code" href="classGosu_1_1Bitmap.html#eb1d21d261788c77aba770361ccdb09f">width</a>() / tilesX; <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <a name="l00132"></a>00132 <span class="keywordflow">if</span> (tileHeight > 0) <a name="l00133"></a>00133 tilesY = bmp.<a class="code" href="classGosu_1_1Bitmap.html#fc5a1fdaaf0453834c3b9ac13342eae6">height</a>() / tileHeight; <a name="l00134"></a>00134 <span class="keywordflow">else</span> <a name="l00135"></a>00135 { <a name="l00136"></a>00136 tilesY = -tileHeight; <a name="l00137"></a>00137 tileHeight = bmp.<a class="code" href="classGosu_1_1Bitmap.html#fc5a1fdaaf0453834c3b9ac13342eae6">height</a>() / tilesY; <a name="l00138"></a>00138 } <a name="l00139"></a>00139 <a name="l00140"></a>00140 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> y = 0; y < tilesY; ++y) <a name="l00141"></a>00141 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> x = 0; x < tilesX; ++x) <a name="l00142"></a>00142 appendTo.push_back(<span class="keyword">typename</span> Container::value_type(<span class="keyword">new</span> <a class="code" href="classGosu_1_1Image.html" title="Provides functionality for drawing rectangular images.">Image</a>(graphics, bmp, <a name="l00143"></a>00143 x * tileWidth, y * tileHeight, tileWidth, tileHeight, <a name="l00144"></a>00144 hardBorders))); <a name="l00145"></a>00145 } <a name="l00146"></a>00146 } <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Sat Feb 7 22:34:53 2009 for Gosu by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address> </body> </html>