Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

plsdlbmp.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plsdlbmp.h,v 1.2 2003/03/08 15:15:51 uzadow Exp $
00005 |
00006 |      Copyright (c) 1996-2003 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLSDLBMP
00012 #define INCL_PLSDLBMP
00013 
00014 #ifndef INCL_PLBITMAP
00015 #include "plbitmap.h"
00016 #endif
00017 
00018 #include <SDL/SDL.h>
00019 
00020 //! Manipulates uncompressed bitmaps stored as SDL surfaces.
00021 //! 32 bpp only. 
00022 class PLSDLBmp : public PLBmp
00023 {
00024 
00025 public:
00026   //! Creates an empty bitmap.
00027   PLSDLBmp
00028     ( int SurfFlags = SDL_SWSURFACE
00029     );
00030 
00031   //! Destroys the bitmap.
00032   virtual ~PLSDLBmp
00033     ();
00034 
00035   //! Copy constructor
00036   PLSDLBmp
00037     ( const PLBmp &Orig
00038     );
00039 
00040   //! Copy constructor
00041   PLSDLBmp
00042     ( const PLSDLBmp &Orig
00043     );
00044 
00045   //! Attach to an existing SDL surface. After the attach, the 
00046   //! bitmap object besomes the owner of the surface. Any previous contents
00047   //! are destroyed.
00048   void Attach
00049     ( SDL_Surface * pSurface
00050     );
00051 
00052 #ifdef _DEBUG
00053   virtual void AssertValid
00054     () const;    // Tests internal object state
00055 #endif
00056 
00057   //! Assignment operator.
00058   PLSDLBmp &operator=
00059     ( const PLBmp &Orig
00060     );
00061 
00062   //! Assignment operator.
00063   PLSDLBmp &operator=
00064     ( const PLSDLBmp &Orig
00065     );
00066 
00067   // PLSDLBmp information
00068 
00069   //! Returns a pointer to the internal SDL surface.
00070   //! Using this pointer, you can bring SDL and paintlib data out of sync
00071   //! easily. Handle with care.
00072   SDL_Surface * GetSurface
00073     ();
00074 
00075   //! Returns the amount of memory used by the object.
00076   long GetMemUsed
00077     ();
00078 
00079   //! Returns number of bytes used per line.
00080   long GetBytesPerLine
00081     ();
00082 
00083   // Static functions
00084 
00085   //! Returns memory needed by a bitmap with the specified attributes.
00086   static long GetMemNeeded
00087     ( PLLONG width,
00088       PLLONG height,
00089       PLWORD BitsPerPixel
00090     );
00091 
00092   //! Returns memory needed by bitmap bits.
00093   static long GetBitsMemNeeded
00094     ( PLLONG width,
00095       PLLONG height,
00096       PLWORD BitsPerPixel
00097     );
00098 
00099 
00100 protected:
00101   // Local functions
00102 
00103   // Create a new bitmap with uninitialized bits. Assumes no memory
00104   // is allocated yet.
00105   virtual void internalCreate
00106     ( PLLONG Width,
00107       PLLONG Height,
00108       PLWORD BitsPerPixel,
00109       bool bAlphaChannel,
00110       bool bIsGreyscale
00111     );
00112 
00113   // Deletes memory allocated by member variables.
00114   virtual void freeMembers
00115     ();
00116 
00117   // Initializes internal table of line addresses.
00118   virtual void initLineArray
00119     ();
00120 
00121 private:  
00122   SDL_Surface * m_pSurface;        // Pointer to the bits.
00123   int m_SurfFlags;
00124 };
00125 
00126 // Note that _both_ these copy constructors are needed. If only the
00127 // second one is there, MSVC generates a default copy
00128 // constructor anyway :-(.
00129 inline PLSDLBmp::PLSDLBmp
00130     ( const PLSDLBmp &Orig
00131     )
00132     : PLBmp ()
00133 {
00134   m_SurfFlags = Orig.m_SurfFlags;
00135   internalCopy (Orig);
00136 }
00137 
00138 inline PLSDLBmp::PLSDLBmp
00139     ( const PLBmp &Orig
00140     )
00141     : PLBmp ()
00142 {
00143   m_SurfFlags = SDL_SWSURFACE;
00144   internalCopy (Orig);
00145 }
00146 
00147 inline PLSDLBmp & PLSDLBmp::operator=
00148     ( const PLBmp &Orig
00149     )
00150 {
00151   PLBmp::operator=(Orig);
00152   return *this;
00153 }
00154 
00155 inline PLSDLBmp & PLSDLBmp::operator=
00156     ( const PLSDLBmp &Orig
00157     )
00158 {
00159   m_SurfFlags = Orig.m_SurfFlags;
00160   PLBmp::operator=(Orig);
00161   return *this;
00162 }
00163 
00164 
00165 #endif
00166 /*
00167 /--------------------------------------------------------------------
00168 |
00169 |      $Log: plsdlbmp.h,v $
00170 |      Revision 1.2  2003/03/08 15:15:51  uzadow
00171 |      Added PLSDLBmp::Attach().
00172 |
00173 |      Revision 1.1  2003/03/08 14:32:08  uzadow
00174 |      Added support for bitmaps in SDL surface format.
00175 |
00176 |
00177 \--------------------------------------------------------------------
00178 */

Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2