28 #define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
53 #define TARGA_HEADER_SIZE 18
62 if (putc(p[0],
file) == EOF) {
73 if (putc(p[0],
file) == EOF) {
76 if (putc(p[1],
file) == EOF) {
87 if (putc(p[2],
file) == EOF) {
90 if (putc(p[1],
file) == EOF) {
93 if (putc(p[0],
file) == EOF) {
105 if (putc(p[2],
file) == EOF) {
108 if (putc(p[1],
file) == EOF) {
111 if (putc(p[0],
file) == EOF) {
114 if (putc(p[3],
file) == EOF) {
124 unsigned int *rect, *rectstart, *temp;
127 for (
y = 0;
y < ibuf->
y;
y++) {
129 rectstart = rect = ibuf->
rect + (
y * ibuf->
x);
139 if (
this == rect[-3]) {
144 }
while (--bytes != 0);
146 copy = rect - rectstart;
161 if (fputc(last - 1,
file) == EOF) {
165 if (
out(*rect++,
file) == EOF) {
168 }
while (--last != 0);
177 while (*rect++ ==
this) {
183 copy = rect - rectstart;
190 if (fputc(255,
file) == EOF) {
197 if (fputc(0,
file) == EOF) {
201 else if (fputc(127 +
copy,
file) == EOF) {
234 if (putc(*rect,
file) == EOF) {
241 else if (ibuf->
planes <= 16) {
244 if (putc(rect[1],
file) == EOF) {
251 else if (ibuf->
planes <= 24) {
255 if (putc(rect[0],
file) == EOF) {
262 else if (ibuf->
planes <= 32) {
267 if (putc(rect[3],
file) == EOF) {
287 buf[16] = (ibuf->
planes + 0x7) & ~0x7;
304 buf[12] = ibuf->
x & 0xff;
305 buf[13] = ibuf->
x >> 8;
306 buf[14] = ibuf->
y & 0xff;
307 buf[15] = ibuf->
y >> 8;
328 switch ((ibuf->
planes + 7) >> 3) {
385 if (tga->
xsize <= 0) {
388 if (tga->
ysize <= 0) {
409 int size = (ibuf->
x * ibuf->
y) - (rect - ibuf->
rect);
411 printf(
"decodetarga: incomplete file, %.1f%% missing\n",
412 100 * ((
float)
size / (ibuf->
x * ibuf->
y)));
415 memset(rect, 0,
size);
419 printf(
"decodetarga: incomplete file, all pixels written\n");
423 static void decodetarga(
struct ImBuf *ibuf,
const unsigned char *mem,
size_t mem_size,
int psize)
425 const unsigned char *mem_end = mem + mem_size;
540 printf(
"decodetarga: count would overwrite %d pixels\n", -
size);
548 static void ldtarga(
struct ImBuf *ibuf,
const unsigned char *mem,
size_t mem_size,
int psize)
550 const unsigned char *mem_end = mem + mem_size;
620 unsigned int *
rect, *cmap =
NULL , cmap_max = 0;
653 cmap =
MEM_callocN(
sizeof(
unsigned int) * cmap_max,
"targa cmap");
679 cmap[
count] = cp_data;
683 for (
int cmap_index = cmap_max - 1; cmap_index > 0; cmap_index >>= 1) {
712 ldtarga(ibuf, mem, mem_size, 0);
715 ldtarga(ibuf, mem, mem_size, 1);
718 ldtarga(ibuf, mem, mem_size, 2);
721 ldtarga(ibuf, mem, mem_size, 3);
746 int cmap_index = *
rect;
747 if (cmap_index >= 0 && cmap_index < cmap_max) {
748 *
rect = cmap[cmap_index];
763 cp[3] = ((mem[1] << 1) & 0xf8);
764 cp[2] = ((mem[0] & 0xe0) >> 2) + ((mem[1] & 0x03) << 6);
765 cp[1] = ((mem[0] << 3) & 0xf8);
776 unsigned int *lrect,
col;
779 lrect = (
unsigned int *)ibuf->
rect;
785 crect[1] = crect[2] = crect[3] =
col;
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ COLOR_ROLE_DEFAULT_BYTE
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
void IMB_flipy(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void colorspace_set_default_role(char *colorspace, int size, int role)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
ImbFormatOptions foptions
static int tga_out2(unsigned int data, FILE *file)
static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
static int tga_out3(unsigned int data, FILE *file)
static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
static bool makebody_tga(ImBuf *ibuf, FILE *file, int(*out)(unsigned int, FILE *))
static bool dumptarga(struct ImBuf *ibuf, FILE *file)
static int tga_out1(unsigned int data, FILE *file)
bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int UNUSED(flags))
static int tga_out4(unsigned int data, FILE *file)
#define TARGA_HEADER_SIZE
bool imb_is_a_targa(const unsigned char *buf, size_t size)
ImBuf * imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE])
static bool checktarga(TARGA *tga, const unsigned char *mem, const size_t size)