Added simple bitmap interface

This commit is contained in:
2022-06-23 11:21:26 -07:00
commit 46248d5ee6
2 changed files with 180 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
#pragma once
#include <iostream>
#include <cstdint>
#include <vector>
#include <tuple>
class Bitmap {
public:
Bitmap(size_t w, size_t h);
void clear();
void setpixel(
size_t row,
size_t col,
uint8_t r,
uint8_t g,
uint8_t b
);
void save(const char *filename) const;
private:
size_t width;
size_t height;
// Pixel data.
// First is a vector of rows,
// Second is a vector of pixels.
// RGB format.
std::vector<
std::vector<
std::tuple<
uint8_t,
uint8_t,
uint8_t
>>
> data;
static void dump_int_to_bytes(
uint64_t a,
uint8_t* bytes,
size_t index,
size_t num_bytes
);
};