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

pldirectfbbmp.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: pldirectfbbmp_8h-source.html,v 1.4 2004/09/15 15:26:29 uzadow Exp $
00005 |
00006 |      Copyright (c) 1996-2003 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLDIRECTFBBMP
00012 #define INCL_PLDIRECTFBBMP
00013 
00014 #ifndef INCL_PLBITMAP
00015 #include "plbitmap.h"
00016 #endif
00017 
00018 #include <directfb.h>
00019 
00020 //! Manipulates bitmaps stored as DirectFB surfaces.
00021 //! 8, 24 and 32 bpp (pixel formats DSPF_ARGB, DSPF_RGB32, DSPF_RGB24, DSPF_A8).
00022 //! The surfaces used are system memory surfaces.  
00023 class PLDirectFBBmp : public PLBmp
00024 {
00025 
00026 public:
00027   //! Sets a pointer to the main DirectFB interface. This needs to be done 
00028   //! before any PLDirectFBBmps get allocated.
00029   static void SetDirectFB
00030     ( IDirectFB * pDirectFB
00031     );
00032 
00033   //! Creates an empty bitmap object.
00034   //! The Create() function allocates a DirectFB system memory surface for this bitmap.
00035   //! Note that only system memory surfaces are supported at the moment.
00036   PLDirectFBBmp
00037     ();
00038 
00039   //! Destroys the bitmap.
00040   virtual ~PLDirectFBBmp
00041     ();
00042 
00043   //! Copy constructor
00044   PLDirectFBBmp
00045     ( const PLBmp &Orig
00046     );
00047 
00048   //! Copy constructor
00049   PLDirectFBBmp
00050     ( const PLDirectFBBmp &Orig
00051     );
00052 
00053   virtual void CreateFromSurface
00054     ( IDirectFBSurface * pSurface,
00055       bool bOwnsSurface
00056     );
00057 
00058 #ifdef _DEBUG
00059   virtual void AssertValid
00060     () const;    // Tests internal object state
00061 #endif
00062 
00063   //! Assignment operator.
00064   PLDirectFBBmp &operator=
00065     ( const PLBmp &Orig
00066     );
00067 
00068   //! Assignment operator.
00069   PLDirectFBBmp &operator=
00070     ( const PLDirectFBBmp &Orig
00071     );
00072 
00073   // PLDirectFBBmp information
00074 
00075   //! Returns a pointer to the internal DirectFB surface. The surface is still
00076   //! owned by the bitmap object.
00077   //! Using this pointer, you can bring DirectFB and paintlib data out of sync
00078   //! easily. Handle with care.
00079   IDirectFBSurface * GetSurface
00080     ();
00081 
00082   //! Returns the amount of memory used by the object.
00083   long GetMemUsed
00084     ();
00085 
00086   //! Returns number of bytes used per line.
00087   long GetBytesPerLine
00088     ();
00089 
00090   // Static functions
00091 
00092   //! Returns memory needed by a bitmap with the specified attributes.
00093   static long GetMemNeeded
00094     ( PLLONG width,
00095       PLLONG height,
00096       PLWORD BitsPerPixel
00097     );
00098 
00099   //! Returns memory needed by bitmap bits.
00100   static long GetBitsMemNeeded
00101     ( PLLONG width,
00102       PLLONG height,
00103       PLWORD BitsPerPixel
00104     );
00105 
00106 
00107 protected:
00108   // Local functions
00109 
00110   // Create a new bitmap with uninitialized bits. Assumes no memory
00111   // is allocated yet.
00112   virtual void internalCreate
00113     ( PLLONG Width,
00114       PLLONG Height,
00115       PLWORD BitsPerPixel,
00116       bool bAlphaChannel,
00117       bool bIsGreyscale
00118     );
00119 
00120   // Deletes memory allocated by member variables.
00121   virtual void freeMembers
00122     ();
00123 
00124   // Initializes internal table of line addresses.
00125   virtual void initLineArray
00126     ();
00127 
00128 private: 
00129   static IDirectFB * s_pDirectFB; 
00130   IDirectFBSurface * m_pSurface;        // Pointer to the bits.
00131   bool m_bOwnsSurface;
00132 };
00133 
00134 // Note that _both_ these copy constructors are needed. If only the
00135 // second one is there, MSVC 6.0 generates a default copy
00136 // constructor anyway :-(.
00137 inline PLDirectFBBmp::PLDirectFBBmp
00138     ( const PLDirectFBBmp &Orig
00139     )
00140     : PLBmp ()
00141 {
00142   internalCopy (Orig);
00143 }
00144 
00145 inline PLDirectFBBmp::PLDirectFBBmp
00146     ( const PLBmp &Orig
00147     )
00148     : PLBmp ()
00149 {
00150   internalCopy (Orig);
00151 }
00152 
00153 inline PLDirectFBBmp & PLDirectFBBmp::operator=
00154     ( const PLBmp &Orig
00155     )
00156 {
00157   PLBmp::operator=(Orig);
00158   return *this;
00159 }
00160 
00161 inline PLDirectFBBmp & PLDirectFBBmp::operator=
00162     ( const PLDirectFBBmp &Orig
00163     )
00164 {
00165   PLBmp::operator=(Orig);
00166   return *this;
00167 }
00168 
00169 
00170 #endif
00171 /*
00172 /--------------------------------------------------------------------
00173 |
00174 |      $Log: pldirectfbbmp_8h-source.html,v $
00174 |      Revision 1.4  2004/09/15 15:26:29  uzadow
00174 |      Linux compatibility changes, doc update.
00174 |
00175 |      Revision 1.4  2004/06/12 14:52:46  uzadow
00176 |      Added CreateFromSurface function.
00177 |
00178 |      Revision 1.3  2004/06/06 12:56:38  uzadow
00179 |      Doxygenified documentation.
00180 |
00181 |      Revision 1.2  2004/04/16 20:14:41  uzadow
00182 |      Changes to make cdoc work.
00183 |
00184 |      Revision 1.1  2003/07/27 13:50:48  uzadow
00185 |      Added support for DirectFB surfaces.
00186 |
00187 |
00188 |
00189 \--------------------------------------------------------------------
00190 */

Generated on Mon Sep 13 16:16:40 2004 for paintlib by doxygen 1.3.2