The Bitmap class is a helper class for working with bitmap data.
More...
#include <bitmap.h>
The Bitmap class is a helper class for working with bitmap data.
- Author
- Sam Twidale (https://samcodes.co.uk/)
◆ Bitmap() [1/3]
geometrize::Bitmap::Bitmap |
( |
std::uint32_t |
width, |
|
|
std::uint32_t |
height, |
|
|
geometrize::rgba |
color |
|
) |
| |
Bitmap Creates a new bitmap.
- Parameters
-
width | The width of the bitmap. |
height | The height of the bitmap. |
color | The starting color of the bitmap (RGBA format). |
11{
13}
std::vector< std::uint8_t > m_data
The bitmap data.
Definition: bitmap.h:85
void fill(geometrize::rgba color)
fill Fills the bitmap with the given color.
Definition: bitmap.cpp:55
std::uint32_t m_height
The height of the bitmap.
Definition: bitmap.h:84
std::uint32_t m_width
The width of the bitmap.
Definition: bitmap.h:83
◆ Bitmap() [2/3]
geometrize::Bitmap::Bitmap |
( |
std::uint32_t |
width, |
|
|
std::uint32_t |
height, |
|
|
const std::vector< std::uint8_t > & |
data |
|
) |
| |
Bitmap Creates a new bitmap from the supplied byte data.
- Parameters
-
width | The width of the bitmap. |
height | The height of the bitmap. |
data | The byte data to fill the bitmap with, must be width * height * depth (4) long. |
16{
17 assert((width * height * 4U) == data.size());
18}
◆ ~Bitmap()
geometrize::Bitmap::~Bitmap |
( |
| ) |
|
|
default |
◆ Bitmap() [3/3]
◆ copyData()
std::vector< std::uint8_t > geometrize::Bitmap::copyData |
( |
| ) |
const |
copyData Gets a copy of the raw bitmap data.
- Returns
- The bitmap data.
◆ fill()
fill Fills the bitmap with the given color.
- Parameters
-
color | The color to fill the bitmap with. |
56{
57 for(std::size_t i = 0; i <
m_data.size(); i += 4U) {
62 }
63}
std::uint8_t a
The blue component (0-255).
Definition: rgba.h:17
std::uint8_t g
The red component (0-255).
Definition: rgba.h:15
std::uint8_t r
Definition: rgba.h:14
std::uint8_t b
The green component (0-255).
Definition: rgba.h:16
◆ getDataRef()
const std::vector< std::uint8_t > & geometrize::Bitmap::getDataRef |
( |
| ) |
const |
getDataRef Gets a reference to the raw bitmap data.
- Returns
- The bitmap data.
◆ getHeight()
std::uint32_t geometrize::Bitmap::getHeight |
( |
| ) |
const |
getHeight Gets the height of the bitmap.
◆ getPixel()
geometrize::rgba geometrize::Bitmap::getPixel |
( |
std::uint32_t |
x, |
|
|
std::uint32_t |
y |
|
) |
| const |
getPixel Gets a pixel color value.
- Parameters
-
x | The x-coordinate of the pixel. |
y | The y-coordinate of the pixel. |
- Returns
- The pixel RGBA color value.
41{
42 const std::size_t index{(
m_width * y + x) * 4U};
44}
The rgba struct is a helper for manipulating RGBA8888 color data.
Definition: rgba.h:13
◆ getWidth()
std::uint32_t geometrize::Bitmap::getWidth |
( |
| ) |
const |
getWidth Gets the width of the bitmap.
◆ operator=()
◆ setPixel()
void geometrize::Bitmap::setPixel |
( |
std::uint32_t |
x, |
|
|
std::uint32_t |
y, |
|
|
geometrize::rgba |
color |
|
) |
| |
setPixel Sets a pixel color value.
- Parameters
-
x | The x-coordinate of the pixel. |
y | The y-coordinate of the pixel. |
color | The pixel RGBA color value. |
47{
48 const std::uint32_t index{(
m_width * y + x) * 4U};
53}
◆ m_data
std::vector<std::uint8_t> geometrize::Bitmap::m_data |
|
private |
◆ m_height
std::uint32_t geometrize::Bitmap::m_height |
|
private |
The height of the bitmap.
◆ m_width
std::uint32_t geometrize::Bitmap::m_width |
|
private |
The documentation for this class was generated from the following files:
- /home/appveyor/projects/geometrize-lib-docs/geometrize-lib/geometrize/geometrize/bitmap/bitmap.h
- /home/appveyor/projects/geometrize-lib-docs/geometrize-lib/geometrize/geometrize/bitmap/bitmap.cpp