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

FXBitmap.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                             B i t m a p    O b j e c t                        *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXBitmap.h,v 1.19 2002/01/18 22:42:51 jeroen Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXBITMAP_H
00025 #define FXBITMAP_H
00026 
00027 #ifndef FXDRAWABLE_H
00028 #include "FXDrawable.h"
00029 #endif
00030 
00031 
00032 // Image rendering hints
00033 enum {
00034   BITMAP_KEEP       = 0x00000001,       // Keep pixel data in client
00035   BITMAP_OWNED      = 0x00000002,       // Pixel data is owned by image
00036   BITMAP_SHMI       = 0x00000020,       // Using shared memory image
00037   BITMAP_SHMP       = 0x00000040        // Using shared memory pixmap
00038   };
00039 
00040 
00041 // Forward declarations
00042 class FXDC;
00043 class FXDCWindow;
00044 class FXDrawable;
00045 class FXTopWindow;
00046 
00047 
00048 /**
00049 * Bitmap is a one bit/pixel image used for patterning and
00050 * stippling operations.
00051 */
00052 class FXAPI FXBitmap : public FXDrawable {
00053   FXDECLARE(FXBitmap)
00054   friend class FXDC;
00055   friend class FXDCWindow;
00056   friend class FXDrawable;
00057   friend class FXTopWindow;
00058 private:
00059 #ifdef WIN32
00060   virtual FXID GetDC() const;
00061   virtual int ReleaseDC(FXID) const;
00062 #endif
00063 protected:
00064   FXuchar *data;                // Pixel data
00065   FXuint   options;             // Options
00066 protected:
00067   FXBitmap();
00068 private:
00069   FXBitmap(const FXBitmap&);
00070   FXBitmap &operator=(const FXBitmap&);
00071 public:
00072 
00073   /// Create an image
00074   FXBitmap(FXApp* a,const void *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
00075 
00076   /// Create bitmap
00077   virtual void create();
00078 
00079   /// Detach from bitmap
00080   virtual void detach();
00081 
00082   /// Destroy bitmap
00083   virtual void destroy();
00084 
00085   /// Render pixels
00086   virtual void render();
00087 
00088   /// Get pixel at x,y
00089   FXbool getPixel(FXint x,FXint y) const;
00090 
00091   /// Change pixel at x,y
00092   void setPixel(FXint x,FXint y,FXbool color);
00093 
00094   /// Resize bitmap to the specified width and height; the contents become undefined
00095   virtual void resize(FXint w,FXint h);
00096 
00097   /// Save object to stream
00098   virtual void save(FXStream& store) const;
00099 
00100   /// Load object from stream
00101   virtual void load(FXStream& store);
00102 
00103   /// Save pixel data only
00104   virtual void savePixels(FXStream& store) const;
00105 
00106   /// Load pixel data only
00107   virtual void loadPixels(FXStream& store);
00108 
00109   /// Cleanup
00110   virtual ~FXBitmap();
00111   };
00112 
00113 
00114 #endif