123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #ifndef IGL_TGA_H
- #define IGL_TGA_H
- // See license in tga.cpp
- /* tga.h - interface for TrueVision (TGA) image file loader */
- #include <stdio.h>
- #ifdef _WIN32
- #include <windows.h>
- #endif
- #if __APPLE__
- # include <OpenGL/gl.h>
- #elif defined(_WIN32)
- # define NOMINMAX
- # include <Windows.h>
- # undef NOMINMAX
- # include <GL/glew.h>
- # include <GL/gl.h>
- #else
- # define GL_GLEXT_PROTOTYPES
- # include <GL/gl.h>
- # include <GL/glext.h>
- #endif
- namespace igl
- {
- typedef struct {
- GLsizei width;
- GLsizei height;
- GLint components;
- GLenum format;
- GLsizei cmapEntries;
- GLenum cmapFormat;
- GLubyte *cmap;
- GLubyte *pixels;
-
- } gliGenericImage;
- typedef struct {
- unsigned char idLength;
- unsigned char colorMapType;
- /* The image type. */
- #define TGA_TYPE_MAPPED 1
- #define TGA_TYPE_COLOR 2
- #define TGA_TYPE_GRAY 3
- #define TGA_TYPE_MAPPED_RLE 9
- #define TGA_TYPE_COLOR_RLE 10
- #define TGA_TYPE_GRAY_RLE 11
- unsigned char imageType;
- /* Color Map Specification. */
- /* We need to separately specify high and low bytes to avoid endianness
- and alignment problems. */
- unsigned char colorMapIndexLo, colorMapIndexHi;
- unsigned char colorMapLengthLo, colorMapLengthHi;
- unsigned char colorMapSize;
- /* Image Specification. */
- unsigned char xOriginLo, xOriginHi;
- unsigned char yOriginLo, yOriginHi;
- unsigned char widthLo, widthHi;
- unsigned char heightLo, heightHi;
- unsigned char bpp;
- /* Image descriptor.
- 3-0: attribute bpp
- 4: left-to-right ordering
- 5: top-to-bottom ordering
- 7-6: zero
- */
- #define TGA_DESC_ABITS 0x0f
- #define TGA_DESC_HORIZONTAL 0x10
- #define TGA_DESC_VERTICAL 0x20
- unsigned char descriptor;
- } TgaHeader;
- typedef struct {
- unsigned int extensionAreaOffset;
- unsigned int developerDirectoryOffset;
- #define TGA_SIGNATURE "TRUEVISION-XFILE"
- char signature[16];
- char dot;
- char null;
- } TgaFooter;
- extern gliGenericImage *gliReadTGA(FILE *fp, char *name, int hflip, int vflip);
- int gli_verbose(int new_verbose);
- extern int gliVerbose(int newVerbose);
- void writeTGA( gliGenericImage* image, FILE *fp);
- } // end of igl namespace
- #ifdef IGL_HEADER_ONLY
- # include "tga.cpp"
- #endif
- #endif
|