summaryrefslogtreecommitdiff
path: root/vgui2/src/fileimage.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 /vgui2/src/fileimage.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'vgui2/src/fileimage.h')
-rw-r--r--vgui2/src/fileimage.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/vgui2/src/fileimage.h b/vgui2/src/fileimage.h
new file mode 100644
index 0000000..182f0d5
--- /dev/null
+++ b/vgui2/src/fileimage.h
@@ -0,0 +1,95 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef __FILEIMAGE_H__
+#define __FILEIMAGE_H__
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <stdio.h>
+
+typedef void *FileHandle_t;
+
+class FileImageStream
+{
+public:
+ virtual void Read(void *pOut, int len)=0;
+
+ // Returns true if there were any Read errors.
+ // Clears error status.
+ virtual bool ErrorStatus()=0;
+};
+
+
+// Use to read out of a memory buffer..
+class FileImageStream_Memory : public FileImageStream
+{
+public:
+ FileImageStream_Memory(void *pData, int dataLen);
+
+ virtual void Read(void *pOut, int len);
+ virtual bool ErrorStatus();
+
+
+private:
+ unsigned char *m_pData;
+ int m_DataLen;
+ int m_CurPos;
+ bool m_bError;
+};
+
+
+
+// Generic image representation..
+class FileImage
+{
+public:
+ FileImage()
+ {
+ Clear();
+ }
+
+ ~FileImage()
+ {
+ Term();
+ }
+
+ void Term()
+ {
+ if(m_pData)
+ delete [] m_pData;
+
+ Clear();
+ }
+
+ // Clear the structure without deallocating.
+ void Clear()
+ {
+ m_Width = m_Height = 0;
+ m_pData = NULL;
+ }
+
+ int m_Width, m_Height;
+ unsigned char *m_pData;
+};
+
+
+// Functions to load/save FileImages.
+bool Load32BitTGA(
+ FileImageStream *fp,
+ FileImage *pImage);
+
+void Save32BitTGA(
+ FileHandle_t fp,
+ FileImage *pImage);
+
+
+#endif
+
+