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

# deBitmap.hpp

Go to the documentation of this file.

    00001 ///////////////////////////////////////////////////////////////////////////////
    00002 /// @file deBitmap.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_H
    00029 #define DEBITMAP_H
    00030
    00031 #include "deGlobalTypes.hpp"
    00032 #include "deResource.hpp"
    00033 #include "deDriver.hpp"
    00034 #include "deWorld.hpp"
    00035
    00036 #if defined(DEBITMAP_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL)
    00037 #   define BITMAP_API   extern "C" DEDLL_EXPORT
    00038 #elif defined(DESTINY3D_STATIC_LINK)
    00039 #   define BITMAP_API   extern "C"
    00040 #else
    00041 #   define BITMAP_API   extern "C" DEDLL_IMPORT
    00042 #endif
    00043
    00044 #ifdef USING_DESTINY3D
    00045 #ifdef _DEBUG
    00046 #   ifdef DESTINY3D_STATIC_LINK
    00047 #       pragma comment(lib, "deBitmap_sd")
    00048 #       pragma comment(lib, "zlib-d")
    00049 #       pragma comment(lib, "libpng-d")
    00050 #   else
    00051 #       pragma comment(lib, "deBitmapd")
    00052 #   endif //DESTINY3D_STATIC_LINK
    00053 #else
    00054 #   ifdef DESTINY3D_STATIC_LINK
    00055 #       pragma comment(lib, "deBitmap_s")
    00056 #       pragma comment(lib, "zlib")
    00057 #       pragma comment(lib, "libpng")
    00058 #   else
    00059 #       pragma comment(lib, "deBitmap")
    00060 #   endif //DESTINY3D_STATIC_LINK
    00061 #endif //_DEBUG
    00062 #endif //USING_DESTINY3D
    00063
    00064
    00065 class IdeDriver;
    00066 class IdeFileSystem;
    00067 class IdeBitmap;
    00068 class IdeBitmapProxy;
    00069
    00070 // factory functions
    00071 /// initialize the bitmap module
    00072 BITMAP_API deBoolean IdeBitmap_Initialize();
    00073 /// create a zero'd bitmap
    00074 BITMAP_API IdeBitmap* IdeBitmap_CreateBitmap();
    00075 /// create a bitmap proxy
    00076 /// @param FromBitmap an IdeBitmap to create a proxy from
    00077 /// @return valid IdeBitmapProxy object if FromBitmap was a NULL or a valid bitmap
    00078 BITMAP_API IdeBitmapProxy* IdeBitmap_CreateProxy(IdeResourceBase* FromBitmap = NULL);
    00079 /// create a bitmap with specific attributes (not cleared)
    00080 BITMAP_API IdeBitmap* IdeBitmap_CreateBitmapWithInfo(long Width, long Height, IdeDriver::BPP Format, deBoolean CubeMap = deFALSE);
    00081 /// get the IdeBitmap resource interface ID for use in IdeResourceBase::GetRscInterface
    00082 BITMAP_API long IdeBitmap_GetRscInterfaceID();
    00083 /// get the IdeBitmapProxy dworld object interface ID for use in IdeWorldObject::GetWOInterface
    00084 BITMAP_API long IdeBitmapProxy_GetWOInterfaceID();
    00085
    00086 /// A bitmap class for holding 2D image data.
    00087 /// Bitmaps can be used for various applications, such as texture-mapping,
    00088 /// terrain heightmapping, screenshot storage, etc. The IdeBitmap class
    00089 /// provides a means for loading, saving, and manipulating bitmap data. Used
    00090 /// with the IdeBitmapProxy class, bitmap data can be stored and loaded with
    00091 /// Destiny3D World files, allowing textures and heightmaps to be compiled into
    00092 /// them. The pixel formats for an IdeBitmap are the same as those used for
    00093 /// textures in IdeDriver::BPP. IdeBitmap stores some texture-specific
    00094 /// information, such as render target status, number of faces (6 for a cubemap),
    00095 /// and number of MIP levels to generate. IdeBitmap also supports blits from one
    00096 /// instance to another, and other compositing and converstion operations such
    00097 /// as copying a grayscale bitmap into the alpha channel of another bitmap, and
    00098 /// converting a grayscale bump-map into an equivalent dot3 normal map.
    00099 /// Related functions: IdeBitmap_CreateBitmap, IdeBitmap_CreateBitmapWithInfo, IdeBitmap_GetRscInterfaceID
    00100 //class IdeBitmap : virtual public IdeResourceBase
    00101 DE3D_INTERFACE(IdeBitmap, IdeResourceBase)
    00102 {
    00103 protected:
    00104     // call IdeResourceBase::Release instead
    00105     virtual ~IdeBitmap() {}
    00106
    00107 public:
    00108     virtual deBoolean       Reset() = 0;
    00109     virtual void            Cleanup() = 0;
    00110
    00111     /// get the raw data contained in the bitmap
    00112     virtual void*           GetData(u32 FaceNum = 0) = 0;
    00113     /// get the width of this bitmap
    00114     virtual long            GetWidth() = 0;
    00115     /// get the height of this bitmap
    00116     virtual long            GetHeight() = 0;
    00117     /// get the pixelformat of this bitmap
    00118     virtual IdeDriver::BPP  GetFormat() = 0;
    00119     /// get the bitdepth of this bitmap (multiple of 8 almost always)
    00120     virtual long            GetBitDepth() = 0;
    00121     /// get the byte depth of this bitmap
    00122     virtual long            GetByteDepth() = 0;
    00123     /// get the total amount of memory consumed by this bitmap
    00124     virtual DWORD           GetImageSize() = 0;
    00125     virtual long            GetScalingFactor() = 0;
    00126     virtual long            GetNumFaces() = 0;
    00127     /// get the color of a certain pixel, given pixel coordinates (returns ARGB format)
    00128     virtual deARGB          GetColorAt(long X, long Y) = 0;
    00129     /// get the color of a certain pixel, given pixel coordinates (using deColor format)
    00130     virtual void            GetFloatColorAt(long X, long Y, deColor & color) = 0;
    00131     /// get whether or not this bitmap is used as a render target
    00132     virtual deBoolean       IsRenderTarget() = 0;
    00133     /// retrieve the number of mip levels for this bitmap
    00134     virtual long            GetMipLevels() = 0;
    00135
    00136     virtual deBoolean       SetData(void *data, long ByteLength, u32 FaceNum = 0) = 0;
    00137     virtual void            SetWidth(long width) = 0;
    00138     virtual void            SetHeight(long height) = 0;
    00139     virtual void            SetFormat(IdeDriver::BPP Format) = 0;
    00140     virtual void            SetBitDepth(long depth) = 0;
    00141     virtual void            SetImageSize(long size) = 0;
    00142     virtual void            SetRenderTarget(deBoolean RenderTarget) = 0;
    00143     virtual void            SetColorAt(long X, long Y, deARGB Color) = 0;
    00144     virtual deBoolean       SetNumFaces(long NumFaces = 1) = 0;
    00145     virtual void            SetMipLevels(long MipLevels = -1) = 0;
    00146
    00147     /// Blitting function. Blits a source bitmap into this bitmap, clamping the edges.
    00148     /// Source bitmap must share the same pixel format as this target.
    00149     virtual deBoolean       CopyRect(const IdeBitmap* &Source, deRect *SourceRect, long TargetX, long TargetY) = 0;
    00150
    00151     virtual deBoolean       SaveToFileSystem(IdeFileSystem *FS, const char *filename) = 0;
    00152     virtual deBoolean       SaveToFile(IdeFile *file) = 0;
    00153
    00154     // internal engine use only
    00155     virtual void*           GetDriverData(long ID) = 0;
    00156     virtual deBoolean       SetDriverData(long ID, void *Data, IdeDriver * Driver) = 0;
    00157
    00158     /// convert this grayscale bitmap into a 32-bit DOT3 bitmap
    00159     virtual deBoolean       ConvertGrayScaleToDot3(long numsamples = 7, deFloat amplify = 0.0f) = 0;
    00160     /// use another bitmap (same height & width) to fill in the alpha channel in this one
    00161     virtual deBoolean       BindGrayScaleAsAlphaMap(IdeBitmap *AlphaMap) = 0;
    00162     virtual deBoolean       DownSampleMIP(void* &source, void* target, long SW, long SH, long SP, long TW, long TH, long TP, IdeDriver::BPP SFormat, IdeDriver::BPP TFormat) = 0;
    00163 };
    00164
    00165 /// Proxy class for storing bitmaps as DWorld objects.
    00166 /// Related functions: IdeBitmap_CreateProxy, IdeBitmapProxy_GetWOInterfaceID
    00167 class IdeBitmapProxy : virtual public IdeWorldObject
    00168 {
    00169 protected:
    00170     virtual ~IdeBitmapProxy() {}
    00171
    00172 public:
    00173     /// give the proxy object a bitmap to work with
    00174     virtual void        SetBitmap(IdeBitmap* bmp) = 0;
    00175     /// retrieve the bitmap that the proxy holds
    00176     virtual IdeBitmap*  GetBitmap() = 0;
    00177     /// give the proxy object a bitmap filename to reference
    00178     virtual void        SetFilename(const char* filename) = 0;
    00179
    00180     /// save the bitmap pixels to a file
    00181     virtual void        SettingSavePixels(deBoolean Save) = 0;
    00182
    00183     // some utility functions for pass-through operations
    00184
    00185     /// get the filename of the bitmap held by the proxy, if it has one
    00186     virtual const char*     GetFilename() = 0;
    00187     virtual void            GetFilenameBuffer(char *buffer, long buffersize) = 0;
    00188     virtual long            GetWidth() = 0;
    00189     virtual long            GetHeight() = 0;
    00190     virtual IdeDriver::BPP  GetFormat() = 0;
    00191 };
    00192
    00193 #endif