Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cImageTGA.h
Go to the documentation of this file.
1 //
6 
7 #ifndef _INC_cImageTGA_H
8 #define _INC_cImageTGA_H
9 #ifndef NO_PRAGMA_ONCE
10 #pragma once
11 #endif
12 
13 #include "cImageBase.h"
15 
16 namespace GrayLib
17 {
19 
20 #pragma pack(push, 1)
21  struct CATTR_PACKED cImageTGAHeader // sizeof = 18 bytes
22  {
25  BYTE m_identsize;
27  BYTE m_imagetype;
28 
32 
33  short m_xstart;
34  short m_ystart;
35  short m_width;
36  short m_height;
38  BYTE m_descriptor;
39 
40  // pixel data follows header
41  };
42 #pragma pack(pop)
43 
45  {
50 
51  typedef cImageBase SUPER_t;
52 
53  public:
56 
57  protected:
58  HRESULT UpdateHeader();
59 
60  public:
61  cImageTGA() noexcept;
62  virtual ~cImageTGA();
63 
64  virtual void SetEmpty() override;
65  HRESULT CreateSurfaceTGA(PIXELS_t cx, PIXELS_t cy, SURF_FORM_TYPE ePixelFormat);
66 
67  virtual HRESULT ReadStream(cStreamInput& strIn) override;
68  virtual HRESULT WriteStream(cStreamOutput* pFile) const override;
69 
70  virtual HRESULT SetCopySurface(const cSurfaceBase& Surf) override;
71 
73  };
74 
76  : public IImageCreator
77  , public cSingleton<cImageTGAType>
78  {
81  public:
83  : cSingleton<cImageTGAType>(this, typeid(cImageTGAType))
84  {
85  }
86  virtual bool IsFileExt(const FILECHAR_t* pszFileExt) const
87  {
88  return cFilePath::IsFileNameExt(pszFileExt, _FN(".tga"));
89  }
90  virtual cImageBasePtr CreateObject() const override
91  {
92  return new cImageTGA;
93  }
94  };
95 };
96 #endif // _INC_cImageTGA_H
#define _FN(x)
like _T(x) macro for static text file names.
Definition: FileName.h:23
#define CATTR_PACKED
Definition: GrayCore.h:87
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cImageBase.h:21
Definition: cImageTGA.h:78
cImageTGAType()
Definition: cImageTGA.h:82
virtual bool IsFileExt(const FILECHAR_t *pszFileExt) const
Definition: cImageTGA.h:86
virtual cImageBasePtr CreateObject() const override
Definition: cImageTGA.h:90
Definition: cImageTGA.h:45
cImageTGAHeader m_Head
Definition: cImageTGA.h:54
cHeapBlock m_Pixels
Allocated memory for the surface pixels.
Definition: cImageTGA.h:55
Definition: cSurfaceBase.h:26
static bool __stdcall IsFileNameExt(const FILECHAR_t *pszFileName, const FILECHAR_t *pszExt) noexcept
Definition: cFilePath.cpp:1006
Definition: cHeap.h:156
Definition: cRefPtr.h:225
Definition: cSingleton.h:127
Definition: cStream.h:306
Definition: cStream.h:126
Definition: cImageBase.h:66
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
SURF_FORM_TYPE
Definition: cSurfaceInfo.h:24
int PIXELS_t
Count of pixels in a dimension of some image/surface.
Definition: cSurfaceInfo.h:20
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
Definition: cImageTGA.h:22
short m_colourmapstart
first colour map entry in palette
Definition: cImageTGA.h:29
BYTE m_nBitsPerPixel
image bits per pixel 8,16,24,32
Definition: cImageTGA.h:37
BYTE m_colourmapbits
number of bits per palette entry 15,16,24,32
Definition: cImageTGA.h:31
short m_height
image height in pixels
Definition: cImageTGA.h:36
BYTE m_imagetype
type of image 0=none,1=indexed,2=RGB,3=grey,+8=RLE packed
Definition: cImageTGA.h:27
short m_width
image width in pixels
Definition: cImageTGA.h:35
BYTE m_descriptor
image descriptor bits (vh flip bits) 00vhaaaa, bit 5 set to 1 the image's vertical origin is the top
Definition: cImageTGA.h:38
short m_xstart
image x origin
Definition: cImageTGA.h:33
BYTE m_colourmaptype
type of colour map 0=none, 1=has palette
Definition: cImageTGA.h:26
short m_ystart
image y origin
Definition: cImageTGA.h:34
BYTE m_identsize
size of ID field that follows 18 byte header (0 usually)
Definition: cImageTGA.h:25
short m_colourmaplength
number of colours in palette
Definition: cImageTGA.h:30