PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: ImageLoaderDDS.h * 00003 * 00004 * Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight 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 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLGRAPHICS_IMAGELOADER_DDS_H__ 00024 #define __PLGRAPHICS_IMAGELOADER_DDS_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLGraphics/Image/ImageLoader.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLGraphics { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 class Image; 00044 struct DDSHeader; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Image loader implementation for DDS file formats 00053 * 00054 * @remarks 00055 * This file format supports GPU texture compression formats like DXT3 and therefore makes it possible to load in 00056 * compressed image data as efficient as possible by directly passing thru the compressed loaded data to the GPU 00057 * without need for any further processing. 00058 * 00059 * @note 00060 * - DirectDraw Surface file format from Microsoft 00061 * - Use e.g. "The Compressonator" from AMD (http://developer.amd.com/tools/compressonator/pages/default.aspx) to open, view, edit and save the dds-file 00062 * - BGR(A) color format is automatically converted to RGB(A) 00063 */ 00064 class ImageLoaderDDS : public ImageLoader { 00065 00066 00067 //[-------------------------------------------------------] 00068 //[ RTTI interface ] 00069 //[-------------------------------------------------------] 00070 pl_class(PLGRAPHICS_RTTI_EXPORT, ImageLoaderDDS, "PLGraphics", PLGraphics::ImageLoader, "Image loader implementation for DDS file formats") 00071 // Properties 00072 pl_properties 00073 pl_property("Formats", "dds,DDS") 00074 pl_property("Load", "1") 00075 pl_property("Save", "1") 00076 pl_properties_end 00077 // Constructors 00078 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00079 // Methods 00080 pl_method_2(Load, pl_ret_type(bool), Image&, PLCore::File&, "Load method", "") 00081 pl_method_2(Save, pl_ret_type(bool), const Image&, PLCore::File&, "Save method", "") 00082 pl_class_end 00083 00084 00085 //[-------------------------------------------------------] 00086 //[ Public RTTI methods ] 00087 //[-------------------------------------------------------] 00088 public: 00089 PLGRAPHICS_API bool Load(Image &cImage, PLCore::File &cFile); 00090 PLGRAPHICS_API bool Save(const Image &cImage, PLCore::File &cFile); 00091 00092 00093 //[-------------------------------------------------------] 00094 //[ Public functions ] 00095 //[-------------------------------------------------------] 00096 public: 00097 /** 00098 * @brief 00099 * Default constructor 00100 */ 00101 PLGRAPHICS_API ImageLoaderDDS(); 00102 00103 /** 00104 * @brief 00105 * Destructor 00106 */ 00107 PLGRAPHICS_API virtual ~ImageLoaderDDS(); 00108 00109 00110 //[-------------------------------------------------------] 00111 //[ Private functions ] 00112 //[-------------------------------------------------------] 00113 private: 00114 /** 00115 * @brief 00116 * Returns bits from a given bit mask 00117 * 00118 * @param[in] nMask 00119 * Bit mask 00120 * @param[out] nShiftLeft 00121 * Receives the shift left 00122 * @param[out] nShiftRight 00123 * Receives the shift right 00124 */ 00125 void GetBitsFromMask(PLCore::uint32 nMask, PLCore::uint32 &nShiftLeft, PLCore::uint32 &nShiftRight) const; 00126 00127 /** 00128 * @brief 00129 * Decompresses a RGB/RGBA image 00130 * 00131 * @param[in] sHeader 00132 * DDS header 00133 * @param[in, out] cImageBuffer 00134 * Image buffer 00135 * @param[in] pnCompressedData 00136 * Data to decompress 00137 */ 00138 void DecompressRGBA(const DDSHeader &sHeader, ImageBuffer &cImageBuffer, const PLCore::uint8 *pnCompressedData) const; 00139 00140 00141 }; 00142 00143 00144 //[-------------------------------------------------------] 00145 //[ Namespace ] 00146 //[-------------------------------------------------------] 00147 } // PLGraphics 00148 00149 00150 #endif // __PLGRAPHICS_IMAGELOADER_DDS_H__
|