CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

memimage.h

00001 /*
00002     Copyright (C) 2000 by Jorrit Tyberghein
00003     Written by Samuel Humphreys
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSGFX_MEMIMAGE_H__
00021 #define __CS_CSGFX_MEMIMAGE_H__
00022 
00023 #include "csextern.h"
00024 #include "csutil/leakguard.h"
00025 #include "imagetools.h"
00026 #include "rgbpixel.h"
00027 #include "imagebase.h"
00028 
00032 class CS_CSGFX_EXPORT csImageMemory : public csImageBase
00033 {
00034 private:
00036   void ConstructCommon();
00038   void ConstructWHDF (int width, int height, int depth, int format);
00040   void ConstructSource (iImage* source);
00042   void ConstructBuffers (int width, int height, void* buffer, 
00043     bool destroy, int format, csRGBpixel *palette);
00044 protected:
00046   int Width;
00048   int Height;
00050   int Depth;
00057   void* Image;
00059   csRGBpixel *Palette;
00061   uint8 *Alpha;
00063   int Format;
00065   bool has_keycolour;
00067   csRGBpixel keycolour;
00069   bool destroy_image;
00070   csImageType imageType;
00071 
00076   csImageMemory (int iFormat);
00086   void SetDimensions (int newWidth, int newHeight);
00087   void SetDimensions (int newWidth, int newHeight, int newDepth);
00088 
00090   void AllocImage();
00092   void EnsureImage();
00096   void FreeImage ();
00097 public:
00098   SCF_DECLARE_IBASE;
00099   CS_LEAKGUARD_DECLARE (csImageMemory);
00100 
00108   csImageMemory (int width, int height, int format = CS_IMGFMT_TRUECOLOR);
00117   csImageMemory (int width, int height, int depth, int format);
00130   csImageMemory (int width, int height, void* buffer, bool destroy,
00131     int format = CS_IMGFMT_TRUECOLOR, csRGBpixel *palette = 0);
00142   csImageMemory (int width, int height, const void* buffer, 
00143     int format = CS_IMGFMT_TRUECOLOR, const csRGBpixel *palette = 0);
00148   csImageMemory (iImage* source);
00153   csImageMemory (iImage* source, int newFormat);
00154 
00155   virtual ~csImageMemory ();
00156 
00158   void* GetImagePtr ();
00160   csRGBpixel* GetPalettePtr ();
00162   uint8* GetAlphaPtr ();
00163 
00164   virtual const void *GetImageData () { return GetImagePtr(); }
00165   virtual int GetWidth () const { return Width; }
00166   virtual int GetHeight () const { return Height; }
00167   virtual int GetDepth () const { return Depth; }
00168 
00169   virtual int GetFormat () const { return Format; }
00170   virtual const csRGBpixel* GetPalette () { return GetPalettePtr(); }
00171   virtual const uint8* GetAlpha () { return GetAlphaPtr(); }
00172 
00173   virtual bool HasKeyColor () const { return has_keycolour; }
00174 
00175   virtual void GetKeyColor (int &r, int &g, int &b) const
00176   { r = keycolour.red; g = keycolour.green; b = keycolour.blue; }
00177 
00179   void Clear (const csRGBpixel &colour);
00180 
00182   void CheckAlpha ();
00192   void SetFormat (int iFormat);
00193 
00195   virtual void SetKeyColor (int r, int g, int b);
00196   virtual void SetKeycolor (int r, int g, int b) { SetKeyColor(r,g,b); }
00198   virtual void ClearKeyColor ();
00199   virtual void ClearKeycolor () { ClearKeyColor(); }
00200 
00205   virtual void ApplyKeyColor ();
00206   virtual void ApplyKeycolor () { ApplyKeyColor(); }
00207 
00208   virtual csImageType GetImageType() const { return imageType; }
00209   void SetImageType (csImageType type) { imageType = type; }
00210 
00211 
00213   bool Copy (iImage* srcImage, int x, int y, int width, int height);
00218   bool CopyScale (iImage* srcImage, int x, int y, int width, int height);
00223   bool CopyTile (iImage* srcImage, int x, int y, int width, int height);
00224 
00236   void ConvertFromRGBA (csRGBpixel* iImage);
00247   void ConvertFromPal8 (uint8* iImage, uint8* alpha, csRGBpixel* iPalette,
00248     int nPalColors = 256);
00259   void ConvertFromPal8 (uint8* iImage, uint8* alpha, 
00260     const csRGBcolor* iPalette, int nPalColors = 256);
00261 };
00262 
00263 #endif // __CS_CSGFX_MEMIMAGE_H__

Generated for Crystal Space by doxygen 1.3.9.1