forked from NewChromantics/SoyLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoyPng.h
86 lines (68 loc) · 2.1 KB
/
SoyPng.h
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
#pragma once
class SoyPixelsImpl;
namespace TPng
{
namespace TColour { enum Type
{
Invalid = -1, // unsupported (do not write to PNG!)
Greyscale = 0,
RGB = 2,
Palette = 3,
GreyscaleAlpha = 4,
RGBA = 6,
};};
namespace TCompression { enum Type
{
Invalid = -1,
DEFLATE = 0,
};};
namespace TFilter { enum Type
{
Invalid = -1,
None = 0,
};};
namespace TFilterNone_ScanlineFilter { enum Type
{
Invalid = -1,
None = 0,
Sub = 1,
Up = 2,
Average = 3,
Paeth = 4,
};};
namespace TInterlace { enum Type
{
Invalid = -1,
None = 0,
};};
// gr: integrate this into TSerialisation! no excuse not to. Export/ImportNative() or something
// gr: these are the bits that are needed outside of SoyPixels
class THeader
{
public:
THeader() :
mCompression ( TCompression::Invalid ),
mFilter ( TFilter::Invalid ),
mInterlace ( TInterlace::Invalid )
{
}
bool IsValid() const;
TCompression::Type mCompression;
TFilter::Type mFilter;
TInterlace::Type mInterlace;
};
void GetMagic(ArrayBridge<char>&& Magic);
bool CheckMagic(TArrayReader& ArrayReader);
bool CheckMagic(ArrayBridge<char>&& PngData);
TColour::Type GetColourType(SoyPixelsFormat::Type Format);
SoyPixelsFormat::Type GetPixelFormatType(TColour::Type Format);
bool GetPngData(Array<char>& PngData,const SoyPixelsImpl& Image,TCompression::Type Compression);
bool GetDeflateData(Array<char>& ChunkData,const ArrayBridge<uint8>& PixelBlock,bool LastBlock,int WindowSize);
bool ReadHeader(SoyPixelsImpl& Pixels,THeader& Header,ArrayBridge<char>& Data,std::stringstream& Error);
bool ReadData(SoyPixelsImpl& Pixels,const THeader& Header,ArrayBridge<char>& Data,std::stringstream& Error);
bool ReadTail(SoyPixelsImpl& Pixels,ArrayBridge<char>& Data,std::stringstream& Error);
// moved from soypixels
bool GetPng(const SoyPixelsImpl& Pixels,ArrayBridge<char>& PngData);
};
std::ostream& operator<< (std::ostream &out,const TPng::TColour::Type &in);
std::ostream& operator<< (std::ostream &out,const TPng::TFilterNone_ScanlineFilter::Type &in);