Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.0 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Methods relating to saving + loading PSD files (photoshop)
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef PSD_H
  8. #define PSD_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "bitmap/imageformat.h" //ImageFormat enum definition
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class CUtlBuffer;
  17. struct Bitmap_t;
  18. class PSDImageResources
  19. {
  20. public:
  21. enum Resource {
  22. eResFileInfo = 0x0404
  23. };
  24. struct ResElement {
  25. Resource m_eType;
  26. // unsigned char m_pReserved[4];
  27. unsigned short m_numBytes;
  28. unsigned char const *m_pvData;
  29. };
  30. public:
  31. explicit PSDImageResources( unsigned int numBytes, unsigned char const *pvBuffer ) : m_numBytes( numBytes ), m_pvBuffer( pvBuffer ) {}
  32. public:
  33. ResElement FindElement( Resource eType ) const;
  34. protected:
  35. unsigned int m_numBytes;
  36. unsigned char const * m_pvBuffer;
  37. };
  38. class PSDResFileInfo
  39. {
  40. public:
  41. enum ResFileInfo {
  42. eTitle = 0x05,
  43. eAuthor = 0x50,
  44. eAuthorTitle = 0x55,
  45. eDescription = 0x78,
  46. eDescriptionWriter = 0x7A,
  47. eKeywords = 0x19,
  48. eCopyrightNotice = 0x74
  49. };
  50. struct ResFileInfoElement {
  51. ResFileInfo m_eType;
  52. unsigned short m_numBytes;
  53. unsigned char const *m_pvData;
  54. };
  55. public:
  56. explicit PSDResFileInfo( PSDImageResources::ResElement res ) : m_res( res ) {}
  57. public:
  58. ResFileInfoElement FindElement( ResFileInfo eType ) const;
  59. protected:
  60. PSDImageResources::ResElement m_res;
  61. };
  62. //-----------------------------------------------------------------------------
  63. // Is a file a PSD file?
  64. //-----------------------------------------------------------------------------
  65. bool IsPSDFile( const char *pFileName, const char *pPathID );
  66. bool IsPSDFile( CUtlBuffer &buf );
  67. //-----------------------------------------------------------------------------
  68. // Returns information about the PSD file
  69. //-----------------------------------------------------------------------------
  70. bool PSDGetInfo( const char *pFileName, const char *pPathID, int *pWidth, int *pHeight, ImageFormat *pImageFormat, float *pSourceGamma );
  71. bool PSDGetInfo( CUtlBuffer &buf, int *pWidth, int *pHeight, ImageFormat *pImageFormat, float *pSourceGamma );
  72. //-----------------------------------------------------------------------------
  73. // Get PSD file image resources, pointers refer into the utlbuffer
  74. //-----------------------------------------------------------------------------
  75. PSDImageResources PSDGetImageResources( CUtlBuffer &buf );
  76. //-----------------------------------------------------------------------------
  77. // Reads the PSD file into the specified buffer
  78. //-----------------------------------------------------------------------------
  79. bool PSDReadFileRGBA8888( CUtlBuffer &buf, Bitmap_t &bitmap );
  80. bool PSDReadFileRGBA8888( const char *pFileName, const char *pPathID, Bitmap_t &bitmap );
  81. #endif // PSD_H