HOG2
utils
BitMap.h
Go to the documentation of this file.
1
/*
2
* BitMapPic.h
3
* hog2
4
*
5
* Created by Nathan Sturtevant on 3/4/11.
6
* Copyright 2011 NS Software. All rights reserved.
7
*
8
*/
9
10
#ifndef BITMAPPIC_H
11
#define BITMAPPIC_H
12
13
#include <stdio.h>
14
#include <vector>
15
#ifndef WIN32
16
#include <stdint.h>
17
#endif
18
#ifdef WIN32
19
#include "pstdint.h"
20
#endif
21
22
struct
BitMapHeader
23
{
24
BitMapHeader
()
25
:
zero
(0),
bfOffBits
(sizeof(
BitMapHeader
)+2),
biSize
(40),
biPlanes
(1),
26
biBitCount
(32),
biCompression
(0),
biSizeImage
(0),
biXPelsPerMeter
(2835),
biYPelsPerMeter
(2835),
27
biClrUsed
(0),
biClrImportant
(0) {}
28
29
uint32_t
bfSize
;
30
uint32_t
zero
;
31
uint32_t
bfOffBits
;
32
33
uint32_t
biSize
;
34
uint32_t
biWidth
;
35
uint32_t
biHeight
;
36
uint16_t
biPlanes
;
37
uint16_t
biBitCount
;
38
uint32_t
biCompression
;
39
uint32_t
biSizeImage
;
40
uint32_t
biXPelsPerMeter
;
41
uint32_t
biYPelsPerMeter
;
42
uint32_t
biClrUsed
;
43
uint32_t
biClrImportant
;
44
};
45
46
class
BitMapPic
47
{
48
public
:
49
BitMapPic
(
int
w,
int
h);
50
BitMapPic
(
const
char
* file);
51
~BitMapPic
();
52
BitMapPic
(
const
BitMapPic
& b);
53
BitMapPic
&
operator=
(
const
BitMapPic
& b);
54
int
GetWidth
() {
return
width
; }
55
int
GetHeight
() {
return
height
; }
56
void
Save
(
const
char
*file);
57
void
SetPixel
(
int
x,
int
y, uint8_t redByte, uint8_t greenByte, uint8_t blueByte, uint8_t alphaByte=0);
58
void
GetPixel
(
int
x,
int
y, uint8_t &redByte, uint8_t &greenByte, uint8_t &blueByte, uint8_t &alphaByte)
const
;
59
uint8_t *
GetBytes
() {
return
&
image
[0]; }
60
61
private
:
62
uint32_t
width
,
height
;
63
uint8_t *
image
;
64
};
65
//
66
//class BitMapPic {
67
//public:
68
// BitMapPic(const char *file);
69
// BitMapPic(int width, int height);
70
// BitMapPic(int width, int height, uint8_t *data);
71
// void Save(const char *file);
72
// void Load(const char *file);
73
// int GetWidth() { return width; }
74
// int GetHeight() { return height; }
75
// void SetPixel(int x, int y, uint8_t redByte, uint8_t greenByte, uint8_t blueByte, uint8_t alphaByte = 0)
76
// {
77
// if (BytesReversed())
78
// {
79
// image[y*width*4+x*4+0] = blueByte;
80
// image[y*width*4+x*4+1] = greenByte;
81
// image[y*width*4+x*4+2] = redByte;
82
// image[y*width*4+x*4+3] = alphaByte;
83
// }
84
// else {
85
// image[y*width*4+x*4+0] = redByte;
86
// image[y*width*4+x*4+1] = greenByte;
87
// image[y*width*4+x*4+2] = blueByte;
88
// image[y*width*4+x*4+3] = alphaByte;
89
// }
90
// }
91
// void GetPixel(int x, int y, uint8_t &redByte, uint8_t &greenByte, uint8_t &blueByte, uint8_t &alphaByte)
92
// {
93
// if (BytesReversed())
94
// {
95
// blueByte = image[y*width*4+x*4+0];
96
// greenByte = image[y*width*4+x*4+1];
97
// redByte = image[y*width*4+x*4+2];
98
// alphaByte = image[y*width*4+x*4+3];
99
// }
100
// else {
101
// redByte = image[y*width*4+x*4+0];
102
// greenByte = image[y*width*4+x*4+1];
103
// blueByte = image[y*width*4+x*4+2];
104
// alphaByte = image[y*width*4+x*4+3];
105
// }
106
// }
107
// uint8_t *GetBytes() { return &image[0]; }
108
// bool BytesReversed() { return bytesReversed; }
109
//private:
110
// uint32_t width, height;
111
// bool bytesReversed;
112
// std::vector<uint8_t> image;
113
//};
114
115
#endif
BitMapHeader::bfOffBits
uint32_t bfOffBits
Definition:
BitMap.h:31
BitMapPic
Definition:
BitMap.h:46
BitMapHeader::biClrImportant
uint32_t biClrImportant
Definition:
BitMap.h:43
BitMapHeader::BitMapHeader
BitMapHeader()
Definition:
BitMap.h:24
BitMapPic::image
uint8_t * image
Definition:
BitMap.h:63
BitMapPic::GetHeight
int GetHeight()
Definition:
BitMap.h:55
BitMapPic::width
uint32_t width
Definition:
BitMap.h:62
BitMapHeader::biPlanes
uint16_t biPlanes
Definition:
BitMap.h:36
BitMapHeader::biSize
uint32_t biSize
Definition:
BitMap.h:33
BitMapPic::height
uint32_t height
Definition:
BitMap.h:62
BitMapHeader::biClrUsed
uint32_t biClrUsed
Definition:
BitMap.h:42
BitMapHeader::biBitCount
uint16_t biBitCount
Definition:
BitMap.h:37
BitMapPic::BitMapPic
BitMapPic(int w, int h)
Definition:
BitMap.cpp:14
BitMapPic::GetWidth
int GetWidth()
Definition:
BitMap.h:54
BitMapHeader::biYPelsPerMeter
uint32_t biYPelsPerMeter
Definition:
BitMap.h:41
BitMapHeader::bfSize
uint32_t bfSize
Definition:
BitMap.h:29
BitMapHeader
Definition:
BitMap.h:22
BitMapPic::SetPixel
void SetPixel(int x, int y, uint8_t redByte, uint8_t greenByte, uint8_t blueByte, uint8_t alphaByte=0)
Definition:
BitMap.cpp:193
BitMapPic::~BitMapPic
~BitMapPic()
Definition:
BitMap.cpp:139
BitMapHeader::biXPelsPerMeter
uint32_t biXPelsPerMeter
Definition:
BitMap.h:40
BitMapPic::Save
void Save(const char *file)
Definition:
BitMap.cpp:169
BitMapPic::GetPixel
void GetPixel(int x, int y, uint8_t &redByte, uint8_t &greenByte, uint8_t &blueByte, uint8_t &alphaByte) const
Definition:
BitMap.cpp:202
BitMapHeader::biCompression
uint32_t biCompression
Definition:
BitMap.h:38
BitMapPic::GetBytes
uint8_t * GetBytes()
Definition:
BitMap.h:59
BitMapHeader::biHeight
uint32_t biHeight
Definition:
BitMap.h:35
BitMapHeader::biWidth
uint32_t biWidth
Definition:
BitMap.h:34
BitMapPic::operator=
BitMapPic & operator=(const BitMapPic &b)
Definition:
BitMap.cpp:150
BitMapHeader::zero
uint32_t zero
Definition:
BitMap.h:30
BitMapHeader::biSizeImage
uint32_t biSizeImage
Definition:
BitMap.h:39
Generated by
1.8.17