libigl v2.5.0
Loading...
Searching...
No Matches
tga.h
Go to the documentation of this file.
1// This file is part of libigl, a simple c++ geometry processing library.
2//
3// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
4//
5// This Source Code Form is subject to the terms of the Mozilla Public License
6// v. 2.0. If a copy of the MPL was not distributed with this file, You can
7// obtain one at http://mozilla.org/MPL/2.0/.
8#ifndef IGL_OPENGL_TGA_H
9#define IGL_OPENGL_TGA_H
10#include "../../igl_inline.h"
11
12#include "../../opengl2/gl.h"
13// See license in tga.cpp
14/* tga.h - interface for TrueVision (TGA) image file loader */
15#include <stdio.h>
16#ifdef _WIN32
17#include <windows.h>
18#endif
19
20namespace igl
21{
22namespace opengl
23{
24
25typedef struct {
26
27 GLsizei width;
28 GLsizei height;
30 GLenum format;
31
32 GLsizei cmapEntries;
33 GLenum cmapFormat;
34 GLubyte *cmap;
35
36 GLubyte *pixels;
37
39
40typedef struct {
41 unsigned char idLength;
42 unsigned char colorMapType;
43
44 /* The image type. */
45#define TGA_TYPE_MAPPED 1
46#define TGA_TYPE_COLOR 2
47#define TGA_TYPE_GRAY 3
48#define TGA_TYPE_MAPPED_RLE 9
49#define TGA_TYPE_COLOR_RLE 10
50#define TGA_TYPE_GRAY_RLE 11
51 unsigned char imageType;
52
53 /* Color Map Specification. */
54 /* We need to separately specify high and low bytes to avoid endianness
55 and alignment problems. */
56 unsigned char colorMapIndexLo, colorMapIndexHi;
57 unsigned char colorMapLengthLo, colorMapLengthHi;
58 unsigned char colorMapSize;
59
60 /* Image Specification. */
61 unsigned char xOriginLo, xOriginHi;
62 unsigned char yOriginLo, yOriginHi;
63
64 unsigned char widthLo, widthHi;
65 unsigned char heightLo, heightHi;
66
67 unsigned char bpp;
68
69 /* Image descriptor.
70 3-0: attribute bpp
71 4: left-to-right ordering
72 5: top-to-bottom ordering
73 7-6: zero
74 */
75#define TGA_DESC_ABITS 0x0f
76#define TGA_DESC_HORIZONTAL 0x10
77#define TGA_DESC_VERTICAL 0x20
78 unsigned char descriptor;
79
80} TgaHeader;
81
82typedef struct {
83 unsigned int extensionAreaOffset;
85#define TGA_SIGNATURE "TRUEVISION-XFILE"
86 char signature[16];
87 char dot;
88 char null;
89} TgaFooter;
90
91IGL_INLINE extern gliGenericImage *gliReadTGA(FILE *fp, char *name, int hflip, int vflip);
92IGL_INLINE int gli_verbose(int new_verbose);
93IGL_INLINE extern int gliVerbose(int newVerbose);
94
95IGL_INLINE void writeTGA( gliGenericImage* image, FILE *fp);
96
97
98
99} // end of igl namespace
100}
101
102#ifndef IGL_STATIC_LIBRARY
103# include "tga.cpp"
104#endif
105
106#endif
#define IGL_INLINE
Definition igl_inline.h:15
void writeTGA(gliGenericImage *image, FILE *fp)
int gli_verbose(int new_verbose)
gliGenericImage * gliReadTGA(FILE *fp, char *name, int hflip, int vflip)
int gliVerbose(int newVerbose)
Definition AABB.h:17
Definition tga.h:82
unsigned int developerDirectoryOffset
Definition tga.h:84
char dot
Definition tga.h:87
unsigned int extensionAreaOffset
Definition tga.h:83
char null
Definition tga.h:88
Definition tga.h:40
unsigned char idLength
Definition tga.h:41
unsigned char colorMapIndexHi
Definition tga.h:56
unsigned char heightHi
Definition tga.h:65
unsigned char widthHi
Definition tga.h:64
unsigned char colorMapLengthHi
Definition tga.h:57
unsigned char descriptor
Definition tga.h:78
unsigned char xOriginHi
Definition tga.h:61
unsigned char colorMapSize
Definition tga.h:58
unsigned char colorMapType
Definition tga.h:42
unsigned char imageType
Definition tga.h:51
unsigned char bpp
Definition tga.h:67
unsigned char yOriginHi
Definition tga.h:62
Definition tga.h:25
GLenum cmapFormat
Definition tga.h:33
GLubyte * cmap
Definition tga.h:34
GLsizei height
Definition tga.h:28
GLsizei width
Definition tga.h:27
GLsizei cmapEntries
Definition tga.h:32
GLubyte * pixels
Definition tga.h:36
GLint components
Definition tga.h:29
GLenum format
Definition tga.h:30