#include <Bmp.hpp>
◆ B()
unsigned char BMP_byte
Definition: Bmp.hpp:9
Color * data
Definition: Bmp.hpp:30
int pos(int x, int y)
Definition: Bmp.hpp:21
◆ copy()
| void Bmp::copy |
( |
const Bmp & |
src | ) |
|
|
inline |
43 for (
int i=0; i<size; ++i) {
int height
Definition: Bmp.hpp:32
int width
Definition: Bmp.hpp:31
◆ G()
◆ get()
| Color& Bmp::get |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
inline |
◆ init()
| void Bmp::init |
( |
int |
pwidth, |
|
|
int |
pheight |
|
) |
| |
|
inline |
◆ pos()
| int Bmp::pos |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
inlineprivate |
◆ R()
◆ read()
| void Bmp::read |
( |
const char * |
filename | ) |
|
|
inline |
sometimes the fileheader is bigger?!?!
67 FILE* f = fopen(filename,
"rb");
72 fread(info,
sizeof(
BMP_byte), 54, f);
74 width = *( (
int*) &info[18]);
75 height = *( (
int*) &info[22]);
76 int psize = *( (
int*) &info[34]);
80 row_padded = (psize/
height);
86 for(
int y =
height-1; y >= 0; --y) {
87 fread(row,
sizeof(
BMP_byte), row_padded, f);
88 for(
int x = 0; x <
width; ++x) {
90 G(x, y) = row[(3*x)+1];
91 R(x, y) = row[(3*x)+2];
BMP_byte & B(int x, int y)
Definition: Bmp.hpp:48
BMP_byte & R(int x, int y)
Definition: Bmp.hpp:56
BMP_byte & G(int x, int y)
Definition: Bmp.hpp:51
◆ write()
| void Bmp::write |
( |
const char * |
filename | ) |
|
|
inline |
98 FILE* f = fopen(filename,
"wb");
100 'B',
'M', 0,0,0,0, 0,0, 0,0, 54,0,0,0,
101 40,0,0,0, 0,0,0,0, 0,0,0,0, 1,0, 24,0,
104 int xbytes = 4 - ((
width * 3) % 4);
105 if (xbytes == 4) xbytes = 0;
108 *( (
int*) &info[2]) = 54 + psize;
109 *( (
int*) &info[18]) =
width;
110 *( (
int*) &info[22]) =
height;
111 *( (
int*) &info[34]) = psize;
113 fwrite(info,
sizeof(
BMP_byte),
sizeof(info), f);
116 for (y=
height-1; y>=0; --y) {
117 for (x=0; x<
width; ++x) {
118 fprintf(f,
"%c",
B(x, y));
119 fprintf(f,
"%c",
G(x, y));
120 fprintf(f,
"%c",
R(x, y));
124 for (n = 0; n < xbytes; ++n) fprintf(f,
"%c", 0);
◆ data
◆ height
◆ width
The documentation for this struct was generated from the following file: