Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/targa.c
| Show All 31 Lines | |||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| # include <io.h> | # include <io.h> | ||||
| #endif | #endif | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_fileops.h" | #include "BLI_fileops.h" | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "imbuf.h" | #include "imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_filetype.h" | #include "IMB_filetype.h" | ||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| #include "IMB_colormanagement_intern.h" | #include "IMB_colormanagement_intern.h" | ||||
| /* this one is only def-ed once, strangely... related to GS? */ | /* this one is only def-ed once, strangely... related to GS? */ | ||||
| #define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) | #define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) | ||||
| static CLG_LogRef LOG = {"imb.targa"}; | |||||
| /***/ | /***/ | ||||
| typedef struct TARGA { | typedef struct TARGA { | ||||
| unsigned char numid; | unsigned char numid; | ||||
| unsigned char maptyp; | unsigned char maptyp; | ||||
| unsigned char imgtyp; | unsigned char imgtyp; | ||||
| short maporig; | short maporig; | ||||
| short mapsize; | short mapsize; | ||||
| ▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | int imb_is_a_targa(const unsigned char *buf) | ||||
| return checktarga(&tga, buf); | return checktarga(&tga, buf); | ||||
| } | } | ||||
| static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect) | static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect) | ||||
| { | { | ||||
| int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect); | int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect); | ||||
| if (size) { | if (size) { | ||||
| printf("decodetarga: incomplete file, %.1f%% missing\n", 100 * ((float)size / (ibuf->x * ibuf->y))); | CLOG_WARN(&LOG, "decodetarga: incomplete file, %.1f%% missing", 100 * ((float)size / (ibuf->x * ibuf->y))); | ||||
| /* not essential but makes displaying partially rendered TGA's less ugly */ | /* not essential but makes displaying partially rendered TGA's less ugly */ | ||||
| memset(rect, 0, size); | memset(rect, 0, size); | ||||
| } | } | ||||
| else { | else { | ||||
| /* shouldn't happen */ | /* shouldn't happen */ | ||||
| printf("decodetarga: incomplete file, all pixels written\n"); | CLOG_WARN(&LOG, "decodetarga: incomplete file, all pixels written"); | ||||
| } | } | ||||
| } | } | ||||
| static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize) | static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize) | ||||
| { | { | ||||
| const unsigned char *mem_end = mem + mem_size; | const unsigned char *mem_end = mem + mem_size; | ||||
| int count, col, size; | int count, col, size; | ||||
| unsigned int *rect; | unsigned int *rect; | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| if (mem > mem_end) | if (mem > mem_end) | ||||
| goto partial_load; | goto partial_load; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (size) { | if (size) { | ||||
| printf("decodetarga: count would overwrite %d pixels\n", -size); | CLOG_WARN(&LOG, "count would overwrite %d pixels", -size); | ||||
| } | } | ||||
| return; | return; | ||||
| partial_load: | partial_load: | ||||
| complete_partial_load(ibuf, rect); | complete_partial_load(ibuf, rect); | ||||
| } | } | ||||
| static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize) | static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize) | ||||
| ▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines | |||||