aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authorjmarshallnz <jmarshallnz@svn>2010-03-21 06:19:36 +0000
committerjmarshallnz <jmarshallnz@svn>2010-03-21 06:19:36 +0000
commit5eac8635829a36183a8f8cc0c5354959be2c1215 (patch)
tree6c1d2810c96bc9f590aa883bc20d6da8fa36f81e /guilib
parent69b29f2294061510242c7e1bfd87ab01af73347d (diff)
added: Decompress of DXT images to CDDSImage
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@28710 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r--guilib/DDSImage.cpp15
-rw-r--r--guilib/DDSImage.h12
2 files changed, 27 insertions, 0 deletions
diff --git a/guilib/DDSImage.cpp b/guilib/DDSImage.cpp
index bbd440a9a4..83dd55fb2c 100644
--- a/guilib/DDSImage.cpp
+++ b/guilib/DDSImage.cpp
@@ -186,6 +186,21 @@ bool CDDSImage::Compress(unsigned int width, unsigned int height, unsigned int p
return true;
}
+bool CDDSImage::Decompress(unsigned char *argb, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *dxt, unsigned int format)
+{
+ if (!argb || !dxt || !(format & XB_FMT_DXT_MASK))
+ return false;
+
+ if (format == XB_FMT_DXT1)
+ squish::DecompressImage(argb, width, height, pitch, dxt, squish::kDxt1 | squish::kSourceBGRA);
+ else if (format == XB_FMT_DXT3)
+ squish::DecompressImage(argb, width, height, pitch, dxt, squish::kDxt3 | squish::kSourceBGRA);
+ else if (format == XB_FMT_DXT5)
+ squish::DecompressImage(argb, width, height, pitch, dxt, squish::kDxt5 | squish::kSourceBGRA);
+
+ return true;
+}
+
void CDDSImage::Allocate(unsigned int width, unsigned int height, unsigned int format)
{
memset(&m_desc, 0, sizeof(m_desc));
diff --git a/guilib/DDSImage.h b/guilib/DDSImage.h
index 54bdc346a7..788cb501d8 100644
--- a/guilib/DDSImage.h
+++ b/guilib/DDSImage.h
@@ -50,6 +50,18 @@ public:
*/
bool Compress(unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
+ /*! \brief Decompress a DXT1/3/5 image to the given buffer
+ Assumes the buffer has been allocated to at least width*height*4
+ \param argb pixel buffer to write to (at least width*height*4 bytes)
+ \param width width of the pixel buffer
+ \param height height of the pixel buffer
+ \param pitch pitch of the pixel buffer
+ \param dxt compressed dxt data
+ \param format format of the compressed dxt data
+ \return true on success, false otherwise
+ */
+ static bool Decompress(unsigned char *argb, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *dxt, unsigned int format);
+
private:
void Allocate(unsigned int width, unsigned int height, unsigned int format);
const char *GetFourCC(unsigned int format) const;