FXBitmap.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             B i t m a p    O b j e c t                        *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 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.37 2006/01/22 17:57:59 fox Exp $                          *
00023 ********************************************************************************/
00024 #ifndef FXBITMAP_H
00025 #define FXBITMAP_H
00026 
00027 #ifndef FXDRAWABLE_H
00028 #include "FXDrawable.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 // Image rendering hints
00034 enum {
00035   BITMAP_KEEP       = 0x00000001,       // Keep pixel data in client
00036   BITMAP_OWNED      = 0x00000002,       // Pixel data is owned by image
00037   BITMAP_SHMI       = 0x00000020,       // Using shared memory image
00038   BITMAP_SHMP       = 0x00000040        // Using shared memory pixmap
00039   };
00040 
00041 
00042 // Forward declarations
00043 class FXDC;
00044 class FXDCWindow;
00045 
00046 
00057 class FXAPI FXBitmap : public FXDrawable {
00058   FXDECLARE(FXBitmap)
00059   friend class FXDC;
00060   friend class FXDCWindow;
00061 private:
00062 #ifdef WIN32
00063   virtual FXID GetDC() const;
00064   virtual int ReleaseDC(FXID) const;
00065 #endif
00066 protected:
00067   FXuchar *data;        // Pixel data
00068   FXint    bytewidth;   // Number of bytes across
00069   FXuint   options;     // Options
00070 protected:
00071   FXBitmap();
00072 private:
00073   FXBitmap(const FXBitmap&);
00074   FXBitmap &operator=(const FXBitmap&);
00075 public:
00076 
00086   FXBitmap(FXApp* a,const void *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
00087 
00089   void setOptions(FXuint opts);
00090 
00092   FXuint getOptions() const { return options; }
00093 
00100   virtual void setData(FXuchar *pix,FXuint opts=0);
00101 
00108   virtual void setData(FXuchar *pix,FXuint opts,FXint w,FXint h);
00109 
00111   FXuchar* getData() const { return data; }
00112 
00114   FXbool getPixel(FXint x,FXint y) const { return (FXbool)((data[y*bytewidth+(x>>3)]>>(x&7))&1); }
00115 
00117   void setPixel(FXint x,FXint y,FXbool color){ color ? data[y*bytewidth+(x>>3)]|=(1<<(x&7)) : data[y*bytewidth+(x>>3)]&=~(1<<(x&7)); }
00118 
00126   virtual void create();
00127 
00132   virtual void detach();
00133 
00138   virtual void destroy();
00139 
00143   virtual void restore();
00144 
00149   virtual void render();
00150 
00155   virtual void release();
00156 
00162   virtual void resize(FXint w,FXint h);
00163 
00168   virtual void scale(FXint w,FXint h);
00169 
00171   virtual void mirror(FXbool horizontal,FXbool vertical);
00172 
00174   virtual void rotate(FXint degrees);
00175 
00182   virtual void crop(FXint x,FXint y,FXint w,FXint h,FXbool color=0);
00183 
00185   virtual void fill(FXbool color);
00186 
00188   virtual void save(FXStream& store) const;
00189 
00191   virtual void load(FXStream& store);
00192 
00194   virtual bool savePixels(FXStream& store) const;
00195 
00197   virtual bool loadPixels(FXStream& store);
00198 
00200   virtual ~FXBitmap();
00201   };
00202 
00203 }
00204 
00205 #endif
00206 

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:19 2009 for TnFOX by doxygen v1.4.7