blob: 182f0d5753660a005c33933d2a2ea02893a482b8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
|