<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>SDLmm::Surface class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.8.1 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>SDLmm::Surface Class Reference</h1>A graphical surface structure which is used to store graphical data. <a href="#_details">More...</a> <p> <code>#include <<a class="el" href="sdlmm__surface_8h-source.html">sdlmm_surface.h</a>></code> <p> Inheritance diagram for SDLmm::Surface:<p><center><img src="classSDLmm_1_1Surface__inherit__graph.gif" border="0" usemap="#SDLmm::Surface_inherit_map" alt="Inheritance graph"></center> <map name="SDLmm::Surface_inherit_map"> <area href="classSDLmm_1_1BaseSurface.html" shape="rect" coords="0,11,133,30"> </map> <center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><a href="classSDLmm_1_1Surface-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0> <tr><td colspan=2><br><h2>Public Methods</h2></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a0">Surface</a> (SDL_Surface *surface)</td></tr> <tr><td> </td><td><font size=-1><em>Constructor from an SDL_Surface*.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a1">Surface</a> (const Surface &other)</td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a2">Surface</a> ()</td></tr> <tr><td> </td><td><font size=-1><em>Create an uninitialized surface.</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>Surface& </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a3">operator=</a> (const Surface &other)</td></tr> <tr><td> </td><td><font size=-1><em>Implementation of operator=.</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>Surface </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a4">Duplicate</a> () const</td></tr> <tr><td nowrap align=right valign=top>virtual bool </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a5">SetDisplayFormat</a> ()</td></tr> <tr><td> </td><td><font size=-1><em>Convert the surface to the display format.</em> <a href="#a5">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>virtual bool </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#a6">SetDisplayFormatAlpha</a> ()</td></tr> <tr><td> </td><td><font size=-1><em>Convert the surface to the display format.</em> <a href="#a6">More...</a><em></em></font><br><br></td></tr> <tr><td colspan=2><br><h2>Static Public Methods</h2></td></tr> <tr><td nowrap align=right valign=top>Surface </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#d0">CreateSurface</a> (const <a class="el" href="classSDLmm_1_1BaseSurface.html">BaseSurface</a> &other)</td></tr> <tr><td nowrap align=right valign=top>Surface </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#d1">CreateSurface</a> (Uint32 flags, int w, int h, int d, Uint32 Rmask=0, Uint32 Gmask=0, Uint32 Bmask=0, Uint32 Amask=0)</td></tr> <tr><td> </td><td><font size=-1><em>Allocate an empty RGB surface.</em> <a href="#d1">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>Surface </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#d2">CreateSurface</a> (void *pixels, int w, int h, int d, int p, Uint32 Rmask=0, Uint32 Gmask=0, Uint32 Bmask=0, Uint32 Amask=0)</td></tr> <tr><td> </td><td><font size=-1><em>Create a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a> from the provided pixel data.</em> <a href="#d2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>Surface </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#d3">LoadBMP</a> (const char *file)</td></tr> <tr><td> </td><td><font size=-1><em>Loads a Windows BMP and returns it as a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a>.</em> <a href="#d3">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>Surface </td><td valign=bottom><a class="el" href="classSDLmm_1_1Surface.html#d4">LoadBMP</a> (const std::string &file)</td></tr> <tr><td> </td><td><font size=-1><em>Loads a Windows BMP and returns a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a>.</em> <a href="#d4">More...</a><em></em></font><br><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> A graphical surface structure which is used to store graphical data. <p> Surfaces represent areas of "graphical" memory, memory that can be drawn to or blitted onto other Surfaces. <p> <p> <dl compact><dt> <b><a class="el" href="todo.html#_todo000002">Todo: </a></b><dd> Implement a better constructor scheme, where the first argument is a dummy class which specified what to do. This would allow a construct where a surface can be loaded from an image file without first having to create an unitialized object.</dl> <p> <dl compact><dt> <b>Author: </b><dd> David Hedbor <<a href="mailto:david@hedbor.org">david@hedbor.org</a>> </dl> <p> <hr><h2>Constructor & Destructor Documentation</h2> <a name="a0" doxytag="SDLmm::Surface::Surface"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> SDLmm::Surface::Surface ( </b></td> <td valign="bottom"><b> SDL_Surface * <em>surface</em> )<code> [inline, explicit]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Constructor from an SDL_Surface*. <p> This creates a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a> object from an existing SDL_Surface. It's very important not to free the original surface since that will cause a problem when the object is destructed (SDL_Surface storage freed twice). Use with caution. </td> </tr> </table> <a name="a1" doxytag="SDLmm::Surface::Surface"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> SDLmm::Surface::Surface ( </b></td> <td valign="bottom"><b> const Surface & <em>other</em> )<code> [inline]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a2" doxytag="SDLmm::Surface::Surface"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> SDLmm::Surface::Surface ( </b></td> <td valign="bottom"><b> )<code> [inline]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Create an uninitialized surface. <p> <dl compact><dt> <b>Warning: </b><dd> Trying to use an uninitialized surface will result in crashes. Most functions to not have any checks to see whether the surface is initialized or not. </dl> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a name="d2" doxytag="SDLmm::Surface::CreateSurface"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface SDLmm::Surface::CreateSurface ( </b></td> <td valign="bottom"><b> void * <em>pixels</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>w</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>h</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>d</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>p</em>, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Rmask</em> = 0, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Gmask</em> = 0, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Bmask</em> = 0, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Amask</em> = 0 )<code> [inline, static]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Create a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a> from the provided pixel data. <p> The data stored in <em>pixels</em> is assumed to be of the depth specified in the parameter <em>d</em>. The pixel data is not copied into the SDL_Surface structure <em><a class="el" href="classSDLmm_1_1BaseSurface.html#n0">me</a></em> so it should no be freed until the <a class="el" href="classSDLmm_1_1Surface.html">Surface</a> object has been destructed<dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>flags</em> </td><td> the type of surface that should be created which is OR'd combination of the values as described in the SDL documentation. </td></tr> <tr><td valign=top><em>w, h</em> </td><td> width and height of the surface to create. </td></tr> <tr><td valign=top><em>d</em> </td><td> color depth in bits per pixel to use for this surface. If zero, use the depth of the current display. </td></tr> <tr><td valign=top><em>p</em> </td><td> pitch the length (pitch) of each scanline in bytes. </td></tr> <tr><td valign=top><em>RGBAmask</em> </td><td> optional binary masks used to retrieve individual color values. </td></tr> </table> </dl> </td> </tr> </table> <a name="d1" doxytag="SDLmm::Surface::CreateSurface"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface SDLmm::Surface::CreateSurface ( </b></td> <td valign="bottom"><b> Uint32 <em>flags</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>w</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>h</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>d</em>, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Rmask</em> = 0, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Gmask</em> = 0, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Bmask</em> = 0, </b></td> </tr> <tr> <td></td> <td><b> Uint32 <em>Amask</em> = 0 )<code> [inline, static]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Allocate an empty RGB surface. <p> If depth is 8 bits an empty palette is allocated for the surface, otherwise a 'packed-pixel' SDL_PixelFormat is created using the [RGBA]mask's provided. The flags specifies<dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>flags</em> </td><td> the type of surface that should be created which is OR'd combination of the values as described in the SDL documentation. </td></tr> <tr><td valign=top><em>w, h</em> </td><td> width and height of the surface to create. </td></tr> <tr><td valign=top><em>d</em> </td><td> color depth in bits per pixel to use for this surface. If zero, use the depth of the current display.</td></tr> <tr><td valign=top><em>RGBAmask</em> </td><td> optional binary masks used to retrieve individual color values. </td></tr> </table> </dl> </td> </tr> </table> <a name="d0" doxytag="SDLmm::Surface::CreateSurface"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface SDLmm::Surface::CreateSurface ( </b></td> <td valign="bottom"><b> const <a class="el" href="classSDLmm_1_1BaseSurface.html">BaseSurface</a> & <em>other</em> )<code> [inline, static]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a4" doxytag="SDLmm::Surface::Duplicate"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface SDLmm::Surface::Duplicate ( </b></td> <td valign="bottom"><b> ) const<code> [inline]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="d4" doxytag="SDLmm::Surface::LoadBMP"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface SDLmm::Surface::LoadBMP ( </b></td> <td valign="bottom"><b> const std::string & <em>file</em> )<code> [inline, static]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Loads a Windows BMP and returns a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a>. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>file</em> </td><td> the file to attempt to load </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> True if the loading succeeded, false otherwise. </dl> </td> </tr> </table> <a name="d3" doxytag="SDLmm::Surface::LoadBMP"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface SDLmm::Surface::LoadBMP ( </b></td> <td valign="bottom"><b> const char * <em>file</em> )<code> [inline, static]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Loads a Windows BMP and returns it as a new <a class="el" href="classSDLmm_1_1Surface.html">Surface</a>. <p> If the image couldn't be loaded, the <a class="el" href="classSDLmm_1_1Surface.html">Surface</a> will be invalid. You can check the success of the image loading using the Surface.valid() method like the example code below. <div class="fragment"><pre> <a class="code" href="classSDLmm_1_1Surface.html">SDLmm::Surface</a> img(SDLmm::Surface::LoadBMP(<font class="stringliteral">"myimage.bmp"</font>)); <font class="keywordflow">if</font>(!img.valid()) { cerr << <font class="stringliteral">"Loading of image myimage.bmp failed!\n"</font>; exit(1); }</pre></div> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>file</em> </td><td> the file to attempt to load </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> True if the loading succeeded, false otherwise. </dl> </td> </tr> </table> <a name="a5" doxytag="SDLmm::Surface::SetDisplayFormat"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> bool SDLmm::Surface::SetDisplayFormat ( </b></td> <td valign="bottom"><b> )<code> [virtual]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Convert the surface to the display format. <p> This function converts the surface to the pixel format and colors of the video framebuffer, making it suitable for fast blitting onto the display surface. <p> If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function. <p> <dl compact><dt> <b>Returns: </b><dd> The functions returns true if the conversion succeeded or false otherwise. If the conversion failed, the <a class="el" href="classSDLmm_1_1BaseSurface.html">BaseSurface</a> object will not have changed. <p> </dl><dl compact><dt> <b>Note: </b><dd> Please note that this function doesn't return a new, modified object like the SDL_DisplayFormat() function does. Thus there is no need to manually free the old surface. <p> </dl><dl compact><dt> <b>See also: </b><dd> <a class="el" href="classSDLmm_1_1Surface.html#a6">SetDisplayFormatAlpha</a>(), <a class="el" href="classSDLmm_1_1BaseSurface.html#a25">SetAlpha</a>(), <a class="el" href="classSDLmm_1_1BaseSurface.html#a24">SetColorKey</a>() </dl> <p> Reimplemented from <a class="el" href="classSDLmm_1_1BaseSurface.html#a42">SDLmm::BaseSurface</a>. </td> </tr> </table> <a name="a6" doxytag="SDLmm::Surface::SetDisplayFormatAlpha"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> bool SDLmm::Surface::SetDisplayFormatAlpha ( </b></td> <td valign="bottom"><b> )<code> [virtual]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Convert the surface to the display format. <p> This function converts the surface to the pixel format and colors of the video framebuffer plus an alpha channel, making it suitable for fast blitting onto the display surface. <p> If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function. <p> <dl compact><dt> <b>Returns: </b><dd> The functions returns true if the conversion succeeded or false otherwise. If the conversion failed, the <a class="el" href="classSDLmm_1_1BaseSurface.html">BaseSurface</a> object will not have changed. <p> </dl><dl compact><dt> <b>Note: </b><dd> Please note that this function doesn't return a new, modified object like the SDL_DisplayFormatAlpha() function does. Thus there is no need to manually free the old surface. <p> </dl><dl compact><dt> <b>See also: </b><dd> <a class="el" href="classSDLmm_1_1Surface.html#a5">SetDisplayFormat</a>(), <a class="el" href="classSDLmm_1_1BaseSurface.html#a25">SetAlpha</a>(), <a class="el" href="classSDLmm_1_1BaseSurface.html#a24">SetColorKey</a>() </dl> <p> Reimplemented from <a class="el" href="classSDLmm_1_1BaseSurface.html#a43">SDLmm::BaseSurface</a>. </td> </tr> </table> <a name="a3" doxytag="SDLmm::Surface::operator="></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> Surface & SDLmm::Surface::operator= ( </b></td> <td valign="bottom"><b> const Surface & <em>other</em> )<code> [inline]</code> </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Implementation of operator=. <p> </td> </tr> </table> <hr>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="sdlmm__surface_8h-source.html">sdlmm_surface.h</a><li><a class="el" href="sdlmm__surface_8cpp.html">sdlmm_surface.cpp</a></ul> <hr> <table cellspacing=10 cellpadding=0 border=0 width=100%> <tr valign=middle><td><font size=-1>Documentation automatically generated by <a href="http://www.stack.nl/~dimitri/doxygen/"><img border=0 align=center src="doxygen.gif" alt="doxygen"></a> written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>.</font></td> <td align=right><font size=-1>Project hosted at <br><a href="http://sourceforge.net"><img align=middle src="http://sourceforge.net/sflogo.php?group_id=25445&type=1" width="88" height="31" border="0" alt="Hosted by SourceForge"></a></font></td></tr></table>