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

pldirectfbbmp.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: pldirectfbbmp.h,v 1.2 2004/04/16 20:14:41 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 #ifdef _DEBUG
00054   virtual void AssertValid
00055     () const;    // Tests internal object state
00056 #endif
00057 
00058   //! Assignment operator.
00059   PLDirectFBBmp &operator=
00060     ( const PLBmp &Orig
00061     );
00062 
00063   //! Assignment operator.
00064   PLDirectFBBmp &operator=
00065     ( const PLDirectFBBmp &Orig
00066     );
00067 
00068   // PLDirectFBBmp information
00069 
00070   //! Returns a pointer to the internal DirectFB surface. The surface is still
00071   //! owned by the bitmap object.
00072   //! Using this pointer, you can bring DirectFB and paintlib data out of sync
00073   //! easily. Handle with care.
00074   IDirectFBSurface * GetSurface
00075     ();
00076 
00077   //! Returns the amount of memory used by the object.
00078   long GetMemUsed
00079     ();
00080 
00081   //! Returns number of bytes used per line.
00082   long GetBytesPerLine
00083     ();
00084 
00085   // Static functions
00086 
00087   //! Returns memory needed by a bitmap with the specified attributes.
00088   static long GetMemNeeded
00089     ( PLLONG width,
00090       PLLONG height,
00091       PLWORD BitsPerPixel
00092     );
00093 
00094   //! Returns memory needed by bitmap bits.
00095   static long GetBitsMemNeeded
00096     ( PLLONG width,
00097       PLLONG height,
00098       PLWORD BitsPerPixel
00099     );
00100 
00101 
00102 protected:
00103   // Local functions
00104 
00105   // Create a new bitmap with uninitialized bits. Assumes no memory
00106   // is allocated yet.
00107   virtual void internalCreate
00108     ( PLLONG Width,
00109       PLLONG Height,
00110       PLWORD BitsPerPixel,
00111       bool bAlphaChannel,
00112       bool bIsGreyscale
00113     );
00114 
00115   // Deletes memory allocated by member variables.
00116   virtual void freeMembers
00117     ();
00118 
00119   // Initializes internal table of line addresses.
00120   virtual void initLineArray
00121     ();
00122 
00123 private: 
00124   static IDirectFB * s_pDirectFB; 
00125   IDirectFBSurface * m_pSurface;        // Pointer to the bits.
00126   DFBSurfaceDescription m_Desc;
00127 };
00128 
00129 // Note that _both_ these copy constructors are needed. If only the
00130 // second one is there, MSVC 6.0 generates a default copy
00131 // constructor anyway :-(.
00132 inline PLDirectFBBmp::PLDirectFBBmp
00133     ( const PLDirectFBBmp &Orig
00134     )
00135     : PLBmp ()
00136 {
00137   internalCopy (Orig);
00138 }
00139 
00140 inline PLDirectFBBmp::PLDirectFBBmp
00141     ( const PLBmp &Orig
00142     )
00143     : PLBmp ()
00144 {
00145   internalCopy (Orig);
00146 }
00147 
00148 inline PLDirectFBBmp & PLDirectFBBmp::operator=
00149     ( const PLBmp &Orig
00150     )
00151 {
00152   PLBmp::operator=(Orig);
00153   return *this;
00154 }
00155 
00156 inline PLDirectFBBmp & PLDirectFBBmp::operator=
00157     ( const PLDirectFBBmp &Orig
00158     )
00159 {
00160   PLBmp::operator=(Orig);
00161   return *this;
00162 }
00163 
00164 
00165 #endif
00166 /*
00167 /--------------------------------------------------------------------
00168 |
00169 |      $Log: pldirectfbbmp.h,v $
00170 |      Revision 1.2  2004/04/16 20:14:41  uzadow
00171 |      Changes to make cdoc work.
00172 |
00173 |      Revision 1.1  2003/07/27 13:50:48  uzadow
00174 |      Added support for DirectFB surfaces.
00175 |
00176 |
00177 |
00178 \--------------------------------------------------------------------
00179 */

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