-
Notifications
You must be signed in to change notification settings - Fork 0
/
tgaimage.h
74 lines (59 loc) · 2.28 KB
/
tgaimage.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
#ifndef tgaimage_h
#define tgaimage_h
/********************************************************************************/
/** **/
/** TGAimage objects create a TGA image file that can then be written to using **/
/** the PutPixel function. **/
/** **/
/********************************************************************************/
#include <fstream>
#include <string.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
class TGAimage {
private:
char* filename; // name of TGA output file
short xsize, ysize; // size of image in pixels - short = 2 bytes
ofstream outfile; // file object for output
ifstream infile; // file object for input
unsigned long image_data_offset; // offset of image data in file (bytes)
char* pix_buff; // buffer - array of pixel values r,g,b or b,g,r
public:
TGAimage(char* name);
//
// Constructor
/////////////////////////////////////////////////////////////////////////
~TGAimage();
//
// Deconstructor
/////////////////////////////////////////////////////////////////////////
void createNew(int x, int y);
//
// Create New : 'Initialises' the current image associated with this
// object ready for writing to. Effectively creating a new
// image.
/////////////////////////////////////////////////////////////////////////
void readImage();
//
// Read Image
/////////////////////////////////////////////////////////////////////////
void setPixel(char red, char green, char blue, int x, int y);
//
// Set Colour Of Pixel x,y
/////////////////////////////////////////////////////////////////////////
void getPixel(int& red, int& green, int& blue, int x, int y);
//
// Get Pixel Colour: pass r,g,b by reference and read values from file,
// put them in r,g,b
////////////////////////////////////////////////////////////////////////
void writeImage();
//
// Writes image from memory to disk
/////////////////////////////////////////////////////////////////////////
void blurImage();
//
// Blurs Image
/////////////////////////////////////////////////////////////////////////
};
#endif