-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTimImage.h
More file actions
150 lines (115 loc) · 2.21 KB
/
Copy pathTimImage.h
File metadata and controls
150 lines (115 loc) · 2.21 KB
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
#ifndef TIMIMAGE_H
#define TIMIMAGE_H
#include <FreeImage.h>
typedef struct {
unsigned short r:5;
unsigned short g:5;
unsigned short b:5;
unsigned short i:1;
} TIM_PIX_16;
#pragma pack(push, 1)
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} TIM_PIX_24;
#pragma pack(pop)
class TimImage {
private:
// TIM image parameters
void *im_pixels;
int im_pmode;
int im_iw;
int im_x,im_y;
int im_w,im_h;
// CLUT image paramters
TIM_PIX_16 *cl_pixels;
int cl_x,cl_y;
int cl_w,cl_h;
public:
enum TIM_ERR {
ERR_OK,
ERR_NOT_FOUND,
ERR_CANT_READ,
ERR_INVALID,
ERR_NO_IMAGE,
ERR_CANT_WRITE
};
enum PMODE {
PMODE_4,
PMODE_8,
PMODE_16,
PMODE_24
};
typedef struct IMPORT_PARAMS
{
int color_depth;
bool set_stp;
bool set_stp_black;
bool use_alpha;
int alpha_threshold;
int stp_threshold;
short image_x,image_y;
short clut_x,clut_y;
} IMPORT_PARAMS;
enum IMPORT_ERR {
IMPORT_ERR_OK,
IMPORT_ERR_CANT_RGB32,
};
TimImage();
virtual ~TimImage();
TIM_ERR LoadTim(const char *filename);
TIM_ERR SaveTim(const char *filename);
TIM_PIX_24 ImagePixel24(int x, int y);
TIM_PIX_16 ImagePixel(int x, int y, int clut_row = 0);
TIM_PIX_16 ClutPixel(int x, int y);
int PixelIndex(int x, int y);
void SetClutPixel(int x, int y, short r, short g, short b, short i);
void Copy(TimImage *src, int copy_pos = 1);
int HasClut() {
if( cl_pixels )
return 1;
return 0;
}
int GetPmode() {
return im_pmode;
}
void GetClutPosition(int &x, int &y) {
x = cl_x;
y = cl_y;
}
void SetClutPosition(int x, int y) {
cl_x = x;
cl_y = y;
}
void GetClutDimensions(int &w, int &h) {
w = cl_w;
h = cl_h;
}
void GetDimensionsVRAM(int &w, int &h) {
w = im_w;
h = im_h;
}
void GetDimensions(int &w, int &h) {
w = im_iw;
h = im_h;
}
void GetPosition(int &x, int &y) {
x = im_x;
y = im_y;
}
void SetPosition(int x, int y) {
im_x = x;
im_y = y;
}
int GetNumCluts() {
return cl_h;
}
void SetImageData(void *pixels, int w, int h, int pmode);
void SetClutData(void *colors, int w, int h);
int AddClutSlot(int nslots);
void DeleteClut(int slot);
int modified;
int blendmode;
};
#endif /* TIMIMAGE_H */