World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл PCX.cpp

См. исходные тексты.

Классы

struct  PCXHeader
 
struct  ColorFormat
 
struct  Format
 

Функции

voidWritePCXHeader (void *pcx_data, int width, int height)
 
voidEncodeOneLine (void *pcx_data, void *line, size_t line_size)
 
void Encode (Format f, const void *picture_data, unsigned int width, unsigned int height, void *pcx_data, int max_buff_size, unsigned int *packed_size)
 

Функции

◆ WritePCXHeader()

void* WritePCXHeader ( void pcx_data,
int  width,
int  height 
)

См. определение в файле PCX.cpp строка 176

176  {
177  int pitch = width;
178  if (width & 1) {
179  pitch = width + 1;
180  }
181 
182  PCXHeader *header = (PCXHeader *)pcx_data;
183  memset(header, 0, sizeof(PCXHeader));
184  header->left = 0;
185  header->up = 0;
186  header->right = width - 1;
187  header->bottom = height - 1;
188  header->pitch = pitch;
189  header->manufacturer = 10;
190  header->version = 5;
191  header->encoding = 1;
192  header->bpp = 8;
193  header->hdpi = 75;
194  header->vdpi = 75;
195  header->planes = 3;
196  header->palette_info = 1;
197 
198  return (uint8_t *)pcx_data + sizeof(PCXHeader);
199 }

Перекрестные ссылки PCXHeader::bottom, PCXHeader::bpp, PCXHeader::encoding, PCXHeader::hdpi, PCXHeader::left, PCXHeader::manufacturer, PCXHeader::palette_info, PCXHeader::pitch, PCXHeader::planes, PCXHeader::right, PCXHeader::up, PCXHeader::vdpi и PCXHeader::version.

Используется в Encode().

+ Граф вызова функции:

◆ EncodeOneLine()

void* EncodeOneLine ( void pcx_data,
void line,
size_t  line_size 
)

См. определение в файле PCX.cpp строка 201

201  {
202  uint8_t *input = (uint8_t *)line;
203  uint8_t *output = (uint8_t *)pcx_data;
204 
205  for (int i = 0; i < line_size; i++) {
206  uint8_t value = *input++;
207  uint8_t count = 1;
208  while ((count < 63) && (i < (line_size - 1)) && (input[1] == value)) {
209  input++;
210  count++;
211  i++;
212  }
213  if ((count > 1) || ((value & 0xC0) != 0)) {
214  *output++ = 0xC0 + count;
215  }
216  *output++ = value;
217  }
218 
219  return output;
220 }

Используется в Encode().

+ Граф вызова функции:

◆ Encode()

void Encode ( Format  f,
const void picture_data,
unsigned int  width,
unsigned int  height,
void pcx_data,
int  max_buff_size,
unsigned int *  packed_size 
)

См. определение в файле PCX.cpp строка 258

260  {
261  uint8_t *output = (uint8_t *)WritePCXHeader(pcx_data, width, height);
262 
263  int pitch = width;
264  if (width & 1) {
265  pitch = width + 1;
266  }
267 
268  uint8_t *lineRGB = new uint8_t[3 * pitch];
269  uint8_t *lineR = (uint8_t *)lineRGB;
270  uint8_t *lineG = (uint8_t *)lineRGB + pitch;
271  uint8_t *lineB = (uint8_t *)lineRGB + 2 * pitch;
272  uint8_t *input = (uint8_t *)picture_data;
273 
274  for (int y = 0; y < height; y++) {
275  for (unsigned int x = 0; x < width; x++) {
276  uint32_t pixel;
277  memcpy(&pixel, input, f.bytes);
278  input += f.bytes;
279  lineR[x] = ((pixel >> f.r.shift) & f.r.mask) << (8 - f.r.bits);
280  lineG[x] = ((pixel >> f.g.shift) & f.g.mask) << (8 - f.g.bits);
281  lineB[x] = ((pixel >> f.b.shift) & f.b.mask) << (8 - f.b.bits);
282  }
283  uint8_t *line = lineRGB;
284  for (int p = 0; p < 3; p++) {
285  output = (uint8_t *)EncodeOneLine(output, line, pitch);
286  line += pitch;
287  }
288  }
289 
290  delete[] lineRGB;
291 
292  if (packed_size != nullptr) {
293  *packed_size = output - (uint8_t*)pcx_data;
294  }
295 }

Перекрестные ссылки EncodeOneLine() и WritePCXHeader().

Используется в PCX::Encode16() и PCX::Encode32().

+ Граф вызовов:
+ Граф вызова функции:
PCXHeader
Definition: PCX.cpp:8
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: SDL_egl.h:1596
PCXHeader::left
int16_t left
Definition: PCX.cpp:13
PCXHeader::palette_info
int16_t palette_info
Definition: PCX.cpp:23
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
PCXHeader::bottom
int16_t bottom
Definition: PCX.cpp:16
input
GLenum GLenum GLenum input
Definition: SDL_opengl_glext.h:9377
PCXHeader::up
int16_t up
Definition: PCX.cpp:14
PCXHeader::pitch
int16_t pitch
Definition: PCX.cpp:22
y
EGLSurface EGLint EGLint y
Definition: SDL_egl.h:1596
PCXHeader::encoding
int8_t encoding
Definition: PCX.cpp:11
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11093
x
EGLSurface EGLint x
Definition: SDL_egl.h:1596
WritePCXHeader
void * WritePCXHeader(void *pcx_data, int width, int height)
Definition: PCX.cpp:176
width
EGLSurface EGLint EGLint EGLint width
Definition: SDL_egl.h:1596
PCXHeader::version
int8_t version
Definition: PCX.cpp:10
EncodeOneLine
void * EncodeOneLine(void *pcx_data, void *line, size_t line_size)
Definition: PCX.cpp:201
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
value
EGLSyncKHR EGLint EGLint * value
Definition: SDL_egl.h:899
uint8_t
unsigned __int8 uint8_t
Definition: SDL_config.h:35
PCXHeader::planes
int8_t planes
Definition: PCX.cpp:21
PCXHeader::hdpi
int16_t hdpi
Definition: PCX.cpp:17
PCXHeader::manufacturer
int8_t manufacturer
Definition: PCX.cpp:9
PCXHeader::bpp
int8_t bpp
Definition: PCX.cpp:12
PCXHeader::right
int16_t right
Definition: PCX.cpp:15
uint32_t
unsigned __int32 uint32_t
Definition: SDL_config.h:39
PCXHeader::vdpi
int16_t vdpi
Definition: PCX.cpp:18