summaryrefslogtreecommitdiff
path: root/public/bitmap/psd.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/bitmap/psd.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/bitmap/psd.h')
-rw-r--r--public/bitmap/psd.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/public/bitmap/psd.h b/public/bitmap/psd.h
new file mode 100644
index 0000000..aae3cbf
--- /dev/null
+++ b/public/bitmap/psd.h
@@ -0,0 +1,105 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Methods relating to saving + loading PSD files (photoshop)
+//
+// $NoKeywords: $
+//===========================================================================//
+
+#ifndef PSD_H
+#define PSD_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "bitmap/imageformat.h" //ImageFormat enum definition
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CUtlBuffer;
+struct Bitmap_t;
+
+class PSDImageResources
+{
+public:
+ enum Resource {
+ eResFileInfo = 0x0404
+ };
+
+ struct ResElement {
+ Resource m_eType;
+ // unsigned char m_pReserved[4];
+ unsigned short m_numBytes;
+ unsigned char const *m_pvData;
+ };
+
+public:
+ explicit PSDImageResources( unsigned int numBytes, unsigned char const *pvBuffer ) : m_numBytes( numBytes ), m_pvBuffer( pvBuffer ) {}
+
+public:
+ ResElement FindElement( Resource eType ) const;
+
+protected:
+ unsigned int m_numBytes;
+ unsigned char const * m_pvBuffer;
+};
+
+class PSDResFileInfo
+{
+public:
+ enum ResFileInfo {
+ eTitle = 0x05,
+ eAuthor = 0x50,
+ eAuthorTitle = 0x55,
+ eDescription = 0x78,
+ eDescriptionWriter = 0x7A,
+ eKeywords = 0x19,
+ eCopyrightNotice = 0x74
+ };
+
+ struct ResFileInfoElement {
+ ResFileInfo m_eType;
+ unsigned short m_numBytes;
+ unsigned char const *m_pvData;
+ };
+
+public:
+ explicit PSDResFileInfo( PSDImageResources::ResElement res ) : m_res( res ) {}
+
+public:
+ ResFileInfoElement FindElement( ResFileInfo eType ) const;
+
+protected:
+ PSDImageResources::ResElement m_res;
+};
+
+
+//-----------------------------------------------------------------------------
+// Is a file a PSD file?
+//-----------------------------------------------------------------------------
+bool IsPSDFile( const char *pFileName, const char *pPathID );
+bool IsPSDFile( CUtlBuffer &buf );
+
+
+//-----------------------------------------------------------------------------
+// Returns information about the PSD file
+//-----------------------------------------------------------------------------
+bool PSDGetInfo( const char *pFileName, const char *pPathID, int *pWidth, int *pHeight, ImageFormat *pImageFormat, float *pSourceGamma );
+bool PSDGetInfo( CUtlBuffer &buf, int *pWidth, int *pHeight, ImageFormat *pImageFormat, float *pSourceGamma );
+
+
+//-----------------------------------------------------------------------------
+// Get PSD file image resources, pointers refer into the utlbuffer
+//-----------------------------------------------------------------------------
+PSDImageResources PSDGetImageResources( CUtlBuffer &buf );
+
+
+//-----------------------------------------------------------------------------
+// Reads the PSD file into the specified buffer
+//-----------------------------------------------------------------------------
+bool PSDReadFileRGBA8888( CUtlBuffer &buf, Bitmap_t &bitmap );
+bool PSDReadFileRGBA8888( const char *pFileName, const char *pPathID, Bitmap_t &bitmap );
+
+
+#endif // PSD_H