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.

95 lines
1.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef __FILEIMAGE_H__
  8. #define __FILEIMAGE_H__
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <stdio.h>
  13. typedef void *FileHandle_t;
  14. class FileImageStream
  15. {
  16. public:
  17. virtual void Read(void *pOut, int len)=0;
  18. // Returns true if there were any Read errors.
  19. // Clears error status.
  20. virtual bool ErrorStatus()=0;
  21. };
  22. // Use to read out of a memory buffer..
  23. class FileImageStream_Memory : public FileImageStream
  24. {
  25. public:
  26. FileImageStream_Memory(void *pData, int dataLen);
  27. virtual void Read(void *pOut, int len);
  28. virtual bool ErrorStatus();
  29. private:
  30. unsigned char *m_pData;
  31. int m_DataLen;
  32. int m_CurPos;
  33. bool m_bError;
  34. };
  35. // Generic image representation..
  36. class FileImage
  37. {
  38. public:
  39. FileImage()
  40. {
  41. Clear();
  42. }
  43. ~FileImage()
  44. {
  45. Term();
  46. }
  47. void Term()
  48. {
  49. if(m_pData)
  50. delete [] m_pData;
  51. Clear();
  52. }
  53. // Clear the structure without deallocating.
  54. void Clear()
  55. {
  56. m_Width = m_Height = 0;
  57. m_pData = NULL;
  58. }
  59. int m_Width, m_Height;
  60. unsigned char *m_pData;
  61. };
  62. // Functions to load/save FileImages.
  63. bool Load32BitTGA(
  64. FileImageStream *fp,
  65. FileImage *pImage);
  66. void Save32BitTGA(
  67. FileHandle_t fp,
  68. FileImage *pImage);
  69. #endif