-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimageTGA.h
89 lines (74 loc) · 2.26 KB
/
imageTGA.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef IMAGETGA_H
#define IMAGETGA_H
#include <stdlib.h>
#include <stdio.h>
#include "project.h"
#include "util.h"
/* TODO: return to the old standard */
typedef struct Header {
unsigned char IDLength;
unsigned char colorMapType;
unsigned char imageType;
/* Color map specification */
unsigned char firstEntryIndex [2];
unsigned char colorMapLength [2];
unsigned char colorMapEntrySize;
/* Image specification */
unsigned char xOrigin [2];
unsigned char yOrigin [2];
unsigned char imageWidth [2];
unsigned char imageHeight [2];
unsigned char pixelDepth;
unsigned char imageDescriptor;
} Header;
/* TGA image types and compressions */
typedef enum {
TypeNoImageData = 0,
TypePaletteIndexed = 1,
TypeRGB = 2,
TypeGrayscale = 3,
TypeCompressedPaletteIndexed = 9,
TypeCompressedRGB = 10,
TypeCompressedGrayscale = 11
} ImageType;
/* Pixel ordering, 4th bit is left-right, 5th bit is bottom-top */
typedef enum {
DescriptorBottomLeft = 0b00000000, /* From bottom left to top right */
DescriptorBottomRight = 0b00010000, /* From bottom right to top left */
DescriptorTopLeft = 0b00100000, /* From top left to bottom right */
DescriptorTopRight = 0b00110000 /* From top right to bottom left */
} ImageDescriptor;
typedef struct InternalImage {
unsigned char colorDepth;
unsigned char dataType; /* TODO: check this */
unsigned char dataFormat; /* TODO: check this */
unsigned short width;
unsigned short height;
unsigned long size;
unsigned char* data;
} InternalImage;
/* TODO: Check formats and what is luminance */
typedef enum {
FormatRGB = 0,
FormatRGBA = 1,
FormatLuminance = 2
} DataFormat;
/* TODO: Check data types and what is luminance */
typedef enum {
DataUnsignedByte = 0
} DataType;
/* TODO: is this needed? */
typedef struct RGB {
unsigned char r;
unsigned char g;
unsigned char b;
} RGB;
typedef struct RGBA {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
} RGBA;
InternalImage* imageLoadTGA(const char* filename);
void deleteImage(InternalImage* image);
#endif