summaryrefslogtreecommitdiffstats
path: root/kernel/kls_psp/fmt_codec_psp_defs.h
blob: a03410e28ed88d0ebe90601779fbcbe211145e1f (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*  This file is part of ksquirrel-libs (http://ksquirrel.sf.net)

    Copyright (c) 2005 Dmitry Baryshev <[email protected]>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation;
    either version 2 of the License, or (at your option) any later
    version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef KSQUIRREL_CODEC_DEFS_psp
#define KSQUIRREL_CODEC_DEFS_psp

static const u8 PSPSignature[32] =
{
    0x50, 0x61, 0x69, 0x6E, 0x74, 0x20, 0x53, 0x68, 0x6F, 0x70, 0x20, 0x50, 0x72, 0x6F, 0x20, 0x49,
    0x6D, 0x61, 0x67, 0x65, 0x20, 0x46, 0x69, 0x6C, 0x65, 0x0A, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00
};

static const u8 GenAttHead[4] = { 0x7E, 0x42, 0x4B, 0x00 };

typedef u8     ILubyte;
typedef u16    ILushort;
typedef u32    ILuint;
typedef s32    ILint;
typedef double ILdouble;

//-----------------------------------------------------------------------------
//
// ImageLib Sources
// Copyright (C) 2000-2002 by Denton Woods
// Last modified: 05/02/2002 <--Y2K Compliant! =]
//
// Filename: src-IL/include/il_psp.h
//
// Description: Reads a Paint Shop Pro file.
//
//-----------------------------------------------------------------------------


// Block identifiers
enum PSPBlockID {
	PSP_IMAGE_BLOCK = 0,			// (0)  General Image Attributes Block (main)
	PSP_CREATOR_BLOCK,				// (1)  Creator Data Block (main)
	PSP_COLOR_BLOCK,				// (2)  Color Palette Block (main and sub)
	PSP_LAYER_START_BLOCK,			// (3)  Layer Bank Block (main)
	PSP_LAYER_BLOCK,				// (4)  Layer Block (sub)
	PSP_CHANNEL_BLOCK,				// (5)  Channel Block (sub)
	PSP_SELECTION_BLOCK,			// (6)  Selection Block (main)
	PSP_ALPHA_BANK_BLOCK,			// (7)  Alpha Bank Block (main)
	PSP_ALPHA_CHANNEL_BLOCK,		// (8)  Alpha Channel Block (sub)
	PSP_COMPOSITE_IMAGE_BLOCK,		// (9)  Composite Image Block (sub)
	PSP_EXTENDED_DATA_BLOCK,		// (10) Extended Data Block (main)
	PSP_TUBE_BLOCK,					// (11) Picture Tube Data Block (main)
	PSP_ADJUSTMENT_EXTENSION_BLOCK,	// (12) Adjustment Layer Block (sub)
	PSP_VECTOR_EXTENSION_BLOCK,		// (13) Vector Layer Block (sub)
	PSP_SHAPE_BLOCK,				// (14) Vector Shape Block (sub)
	PSP_PAINTSTYLE_BLOCK,			// (15) Paint Style Block (sub)
	PSP_COMPOSITE_IMAGE_BANK_BLOCK, // (16) Composite Image Bank (main)
	PSP_COMPOSITE_ATTRIBUTES_BLOCK, // (17) Composite Image Attr. (sub)
	PSP_JPEG_BLOCK,					// (18) JPEG Image Block (sub)
	PSP_LINESTYLE_BLOCK,			// (19) Line Style Block (sub)
	PSP_TABLE_BANK_BLOCK,			// (20) Table Bank Block (main)
	PSP_TABLE_BLOCK,				// (21) Table Block (sub)
	PSP_PAPER_BLOCK,				// (22) Vector Table Paper Block (sub)
	PSP_PATTERN_BLOCK,				// (23) Vector Table Pattern Block (sub)
};


// Bitmap type
enum PSPDIBType {
	PSP_DIB_IMAGE = 0,	// Layer color bitmap
	PSP_DIB_TRANS_MASK,	// Layer transparency mask bitmap
	PSP_DIB_USER_MASK,	// Layer user mask bitmap
	PSP_DIB_SELECTION,	// Selection mask bitmap
	PSP_DIB_ALPHA_MASK,	// Alpha channel mask bitmap
	PSP_DIB_THUMBNAIL	// Thumbnail bitmap
};

// Channel types
enum PSPChannelType {
	PSP_CHANNEL_COMPOSITE = 0,	// Channel of single channel bitmap
	PSP_CHANNEL_RED,			// Red channel of 24 bit bitmap
	PSP_CHANNEL_GREEN,			// Green channel of 24 bit bitmap
	PSP_CHANNEL_BLUE			// Blue channel of 24 bit bitmap
};

// Possible metrics used to measure resolution
enum PSP_METRIC { 
	PSP_METRIC_UNDEFINED = 0,	// Metric unknown
	PSP_METRIC_INCH,			// Resolution is in inches
	PSP_METRIC_CM				// Resolution is in centimeters
};


// Possible types of compression.
enum PSPCompression {
	PSP_COMP_NONE = 0,	// No compression
	PSP_COMP_RLE,		// RLE compression
	PSP_COMP_LZ77,		// LZ77 compression
	PSP_COMP_JPEG		// JPEG compression (only used by thumbnail and composite image)
};

// Picture tube placement mode.
enum TubePlacementMode {
	tpmRandom,		// Place tube images in random intervals
	tpmConstant		// Place tube images in constant intervals
};

// Picture tube selection mode.
enum TubeSelectionMode {
	tsmRandom,		// Randomly select the next image in tube to display
	tsmIncremental,	// Select each tube image in turn
	tsmAngular,		// Select image based on cursor direction
	tsmPressure,	// Select image based on pressure (from pressure-sensitive pad)
	tsmVelocity		// Select image based on cursor speed
};

// Extended data field types.
enum PSPExtendedDataID {
	PSP_XDATA_TRNS_INDEX = 0	// Transparency index field
};

// Creator field types.
enum PSPCreatorFieldID {
	PSP_CRTR_FLD_TITLE = 0,		// Image document title field
	PSP_CRTR_FLD_CRT_DATE,		// Creation date field
	PSP_CRTR_FLD_MOD_DATE,		// Modification date field
	PSP_CRTR_FLD_ARTIST,		// Artist name field
	PSP_CRTR_FLD_CPYRGHT,		// Copyright holder name field
	PSP_CRTR_FLD_DESC,			// Image document description field
	PSP_CRTR_FLD_APP_ID,		// Creating app id field
	PSP_CRTR_FLD_APP_VER,		// Creating app version field
};

// Creator application identifiers.
enum PSPCreatorAppID {
	PSP_CREATOR_APP_UNKNOWN = 0,	// Creator application unknown
	PSP_CREATOR_APP_PAINT_SHOP_PRO	// Creator is Paint Shop Pro
};

// Layer types.
enum PSPLayerType {
	PSP_LAYER_NORMAL = 0,			// Normal layer
	PSP_LAYER_FLOATING_SELECTION	// Floating selection layer
};

struct PSPRECT
{
	ILuint x1,y1,x2,y2;
} PACKED;

struct PSPHEAD
{
	char		FileSig[32];
	ILushort	MajorVersion;
	ILushort	MinorVersion;
} PACKED;

struct BLOCKHEAD
{
	ILubyte		HeadID[4];
	ILushort	BlockID;
	ILuint		BlockLen;
} PACKED;

struct GENATT_CHUNK
{
	ILint		Width;
	ILint		Height;
	ILdouble	Resolution;
	ILubyte		ResMetric;
	ILushort	Compression;
	ILushort	BitDepth;
	ILushort	PlaneCount;
	ILuint		ColourCount;
	ILubyte		GreyscaleFlag;
	ILuint		SizeOfImage;
	ILint		ActiveLayer;
	ILushort	LayerCount;
	ILuint		GraphicContents;
} PACKED;

struct LAYERINFO_CHUNK
{
	ILubyte		LayerType;
	PSPRECT		ImageRect;
	PSPRECT		SavedImageRect;
	ILubyte		Opacity;
	ILubyte		BlendingMode;
	ILubyte		LayerFlags;
	ILubyte		TransProtFlag;
	ILubyte		LinkID;
	PSPRECT		MaskRect;
	PSPRECT		SavedMaskRect;
	ILubyte		MaskLinked;
	ILubyte		MaskDisabled;
	ILubyte		InvertMaskBlend;
	ILushort	BlendRange;
	ILubyte		SourceBlend1[4];
	ILubyte		DestBlend1[4];
	ILubyte		SourceBlend2[4];
	ILubyte		DestBlend2[4];
	ILubyte		SourceBlend3[4];
	ILubyte		DestBlend3[4];
	ILubyte		SourceBlend4[4];
	ILubyte		DestBlend4[4];
	ILubyte		SourceBlend5[4];
	ILubyte		DestBlend5[4];
} PACKED;

struct LAYERBITMAP_CHUNK
{
	ILushort	NumBitmaps;
	ILushort	NumChannels;
} PACKED;

struct CHANNEL_CHUNK
{
	ILuint		CompLen;
	ILuint		Length;
	ILushort	BitmapType;
	ILushort	ChanType;
} PACKED;

struct ALPHAINFO_CHUNK
{
	PSPRECT		AlphaRect;
	PSPRECT		AlphaSavedRect;
} PACKED;

struct ALPHA_CHUNK
{
	ILushort	BitmapCount;
	ILushort	ChannelCount;
} PACKED;

#endif