Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# deBitmap_priv.hpp

Go to the documentation of this file.

    00001 ///////////////////////////////////////////////////////////////////////////////
    00002 /// @file deBitmap_priv.hpp
    00003 ///
    00004 /// @brief bitmap loading & conversion
    00005 ///
    00006 /// @author Assassin, Hootie, paradoxnj
    00007 ///
    00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
    00009 /// contents of this file is subject to the Destiny3D Member License which
    00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
    00011 ///
    00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
    00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
    00014 /// for any particular purpose.
    00015 ///
    00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
    00017 ///
    00018 /// <hr>
    00019 ///                                 Change History
    00020 /// <hr>
    00021 ///
    00022 /// @date Jan 2002
    00023 /// @author Assassin
    00024 /// @remarks Initial Creation
    00025 ///
    00026 ///////////////////////////////////////////////////////////////////////////////
    00027
    00028 #ifndef DEBITMAP_PRIV_H
    00029 #define DEBITMAP_PRIV_H
    00030
    00031 #include "deList.hpp"
    00032 #include "deBitmap.hpp"
    00033 #include "deWorld_Helper.hpp"
    00034 #include "deArray.hpp"
    00035 #include "deResource_Helper.hpp"
    00036
    00037 class deBitmap : public deResourceBase, public IdeBitmap
    00038 {
    00039     struct DriverBitmapEntry
    00040     {
    00041         long ID;                //id of the driver
    00042         void *Data;             //a pointer to data the driver wants to store
    00043         IdeDriver * Driver;     // a pointer to the driver so that the buffer can be properly freed
    00044     };
    00045
    00046 public:
    00047     deBitmap();
    00048     deBitmap(const char *filename);
    00049     void * GetRscInterface(long interface_id);
    00050
    00051 protected:
    00052     // call IdeResourceBase::Release instead
    00053     virtual ~deBitmap();
    00054
    00055 protected:
    00056     deTArray<u8*>               m_Data;
    00057     IdeDriver::BPP              m_Format;
    00058
    00059     long                        m_Width;
    00060     long                        m_Height;
    00061     long                        m_ByteDepth;
    00062     long                        m_ImageSize;
    00063     long                        m_MipLevels;
    00064     deBoolean                   m_RenderTarget;
    00065     deTList <DriverBitmapEntry> m_DriverData;   //info that drivers can store
    00066
    00067     void        SetBitDepth(long depth);
    00068     long        WrappedIndex(long X, long Y);
    00069     long        WrappedIndex(long X, long Y, long Width, long Height);
    00070     deBoolean   DownSampleDXTC(void* &source, void* target, long SP, long SW, long SH, long TP, long TH,
    00071                                IdeDriver::BPP SFormat, IdeDriver::BPP TFormat);
    00072
    00073 public:
    00074
    00075     deBoolean LoadBMPFile(IdeFile *file);
    00076     deBoolean LoadTGAFile(IdeFile *file);
    00077     deBoolean LoadPCXFile(IdeFile *file);
    00078     deBoolean LoadPNGFile(IdeFile *file);
    00079     deBoolean LoadDDSFile(IdeFile *file);
    00080     deBoolean LoadCMAPFile(IdeFile *file, const char* filename);
    00081     friend IdeBitmap* IdeBitmap_CreateBitmapWithInfo(long Width, long Height, IdeDriver::BPP Format);
    00082     friend long BPPByteDepth(IdeDriver::BPP BPPType);
    00083
    00084 public:
    00085     deBoolean       Reset();
    00086     void            Cleanup();
    00087
    00088     void*           GetData(u32 FaceNum);
    00089     long            GetWidth();
    00090     long            GetHeight();
    00091     IdeDriver::BPP  GetFormat();
    00092     long            GetBitDepth();
    00093     long            GetByteDepth();
    00094     DWORD           GetImageSize();
    00095     long            GetNumFaces();
    00096     deBoolean       IsRenderTarget();
    00097     long            GetScalingFactor();
    00098     deARGB          GetColorAt(long X, long Y);
    00099     void            GetFloatColorAt(long X, long Y, deColor & color);
    00100     long            GetMipLevels();
    00101
    00102     deBoolean       SetData(void *data, long ByteLength, u32 FaceNum);
    00103     void            SetWidth(long width);
    00104     void            SetHeight(long height);
    00105     void            SetFormat(IdeDriver::BPP Format);
    00106     void            SetImageSize(long size);
    00107     void            SetRenderTarget(deBoolean RenderTarget);
    00108     void            SetColorAt(long X, long Y, deARGB Color);
    00109     void            SetColorAt(long X, long Y, const deColor & color);
    00110     deBoolean       SetNumFaces(long NumFaces);
    00111     void            SetMipLevels(long MipLevels);
    00112
    00113     deBoolean       CopyRect(const IdeBitmap* &Source, deRect *SourceRect, long TargetX, long TargetY);
    00114
    00115     deBoolean       SaveToFileSystem(IdeFileSystem *FS, const char *filename);
    00116     deBoolean       SaveToFile(IdeFile *file);
    00117
    00118     void*           GetDriverData(long ID);
    00119     deBoolean       SetDriverData(long ID, void *Data, IdeDriver * Driver);
    00120
    00121     deBoolean       ConvertGrayScaleToDot3(long numsamples, deFloat amplify);
    00122     deBoolean       BindGrayScaleAsAlphaMap(IdeBitmap *AlphaMap);
    00123     deBoolean       DownSampleMIP(void* &source, void* target, long SW, long SH, long SP,
    00124                                     long TW, long TH, long TP, IdeDriver::BPP SFormat, IdeDriver::BPP TFormat);
    00125
    00126     IdeResourceBase *MakeCopy();
    00127
    00128     static long     s_BitmapRscInterfaceID;
    00129 };
    00130
    00131 class deBitmapProxy : public deWorldObject, virtual public IdeBitmapProxy
    00132 {
    00133 protected:
    00134     virtual ~deBitmapProxy();
    00135
    00136 public:
    00137     deBitmapProxy(IdeBitmap* bmp = NULL);
    00138
    00139     WorldObjectClassDef;
    00140     void*       GetWOInterface(long interface_id);
    00141
    00142     void        SetBitmap(IdeBitmap* bmp);
    00143     IdeBitmap*  GetBitmap();
    00144     void        SetFilename(const char* filename);
    00145
    00146     void        SettingSavePixels(deBoolean Save);
    00147
    00148     const char*     GetFilename();
    00149     void            GetFilenameBuffer(char *buffer, long buffersize);
    00150     long            GetWidth();
    00151     long            GetHeight();
    00152     IdeDriver::BPP  GetFormat();
    00153
    00154     static long     s_BitmapProxyWOInterfaceID;
    00155
    00156 private:
    00157     IdeBitmap* m_BMP;
    00158     char m_BitmapName[256];
    00159     deBoolean m_SavePixels;
    00160 };
    00161
    00162 // helper functions
    00163 void        GetColorIn(u8* data, IdeDriver::BPP Format, deColor &Color);
    00164 void        SetColorIn(u8* data, IdeDriver::BPP Format, deColor Color);
    00165 deBoolean   DecompressDXTC(const void* source, void* target,
    00166                            long Width, long Height, long TP,
    00167                            IdeDriver::BPP SFormat, IdeDriver::BPP TFormat);
    00168 deBoolean   DecompressDXT1(const void* source, void* target,
    00169                            long Width, long Height, long TP,
    00170                            IdeDriver::BPP TFormat);
    00171 deBoolean   DecompressDXT2(const void* source, void* target,
    00172                            long Width, long Height, long TP,
    00173                            IdeDriver::BPP TFormat);
    00174 deBoolean   DecompressDXT3(const void* source, void* target,
    00175                            long Width, long Height, long TP,
    00176                            IdeDriver::BPP TFormat);
    00177 deBoolean   DecompressDXT4(const void* source, void* target,
    00178                            long Width, long Height, long TP,
    00179                            IdeDriver::BPP TFormat);
    00180 deBoolean   DecompressDXT5(const void* source, void* target,
    00181                            long Width, long Height, long TP,
    00182                            IdeDriver::BPP TFormat);
    00183
    00184 #endif