56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
/*
|
|
ptrnt - print labels on linux
|
|
Copyright (C) 2023 Moritz Martinius
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
namespace ptprnt::graphics {
|
|
|
|
typedef uint8_t ALPHA8; // Alpha only, 8 bit per pixel
|
|
typedef uint32_t RGBX8; // RGB, least significant byte unused, 8 bit per channel
|
|
typedef uint32_t RGBA8; // RGB, least significant byte alpha, 8 bit per channel
|
|
typedef uint32_t ARGB8; // RGB, most significant byte alpha, 8 bit per channel
|
|
|
|
template <class T>
|
|
class Bitmap {
|
|
public:
|
|
Bitmap(uint16_t width, uint16_t height);
|
|
~Bitmap() = default;
|
|
|
|
uint16_t getWidth();
|
|
uint16_t getHeight();
|
|
std::optional<std::vector<T>> getLine(uint16_t line);
|
|
std::optional<std::vector<T>> getRow(uint16_t row);
|
|
|
|
private:
|
|
uint16_t mWidth;
|
|
uint16_t mHeight;
|
|
std::vector<T> mPixels;
|
|
};
|
|
|
|
// force compiler to generate class for type ALPHA8 and RGBX8
|
|
template class Bitmap<ALPHA8>;
|
|
template class Bitmap<RGBX8>;
|
|
|
|
} // namespace ptprnt::graphics
|