-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImage.h
71 lines (67 loc) · 1.63 KB
/
Image.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
#ifndef __IMAGE
#define __IMAGE
#include <stdio.h>
/**
* Esta estrutura contem o cabecalho da imagem bmp
* Contem informacoes do BITMAPINFOHEADER, sendo que qualquer outra coisa eh desconsiderada
* http://en.wikipedia.org/wiki/BMP_file_format
*/
typedef struct {
//Bitmap File Header
unsigned short type;
unsigned int size;
unsigned short reserved1;
unsigned short reserved2;
unsigned int starting_pos;
//DIP Header
unsigned int DIPSize;
int width;
int height;
unsigned short color_planes;
unsigned short bpp;
unsigned int compression_method;
unsigned int bitmap_size;
int resolution_x;
int resolution_y;
unsigned int ncolors;
unsigned int important_colors;
} BMPHeader;
/**
* Estrutura contendo a imagem em si.
*/
typedef struct {
BMPHeader *header;
//Raw_Data
unsigned char **R;
unsigned char **G;
unsigned char **B;
} BMPImage;
/**
* Instancia um novo cabecalho.
*/
BMPHeader *newBMPHeader();
/**
* Le o cabecalho de um arquivo bmp.
*/
BMPHeader *readBMPHeader(FILE *fp);
/**
* Escreve o cabecalho bmp no arquivo, e preenche com zeros ate a posicao inicial para escrita da matriz.
*/
void writeBMPHeader(FILE *fp, BMPHeader *bmp);
/**
* Le um arquivo BMP e extrai suas informacoes.
*/
BMPImage *readBMP(FILE *fp);
/**
* Escreve um arquivo BMP com a matriz e cabecalho dados.
*/
void writeBMP(FILE *fp, BMPImage *bmp);
/**
* Calcula os valores "bitmap_size" e "size" do cabecalho do arquivo
*/
void make_BMPHeader(BMPImage *bmp);
/**
* Libera a memoria alocada pelo BMPImage.
*/
void freeBMP(BMPImage *bmp);
#endif