Generate labels with pangocairo (#8)
All checks were successful
Build ptprnt / build (push) Successful in 3m41s
All checks were successful
Build ptprnt / build (push) Successful in 3m41s
Goal of this PR is to have some basic labels generated with pangocairo - size of the canvas should be matching the input text and grow/shrink accordingly - basic formatting options like fontsize and align should be working Reviewed-on: moritz/ptouch-prnt#8
This commit was merged in pull request #8.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
ptrnt - print labels on linux
|
||||
Copyright (C) 2023 Moritz Martinius
|
||||
Copyright (C) 2023-2025 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
|
||||
@@ -19,19 +19,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#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
|
||||
using ALPHA8 = std::uint8_t; // Alpha only, 8 bit per pixel
|
||||
using RGBX8 = std::uint32_t; // RGB, least significant byte unused, 8 bit per channel
|
||||
using RGBA8 = std::uint32_t; // RGB, least significant byte alpha, 8 bit per channel
|
||||
using ARGB8 = std::uint32_t; // RGB, most significant byte alpha, 8 bit per channel
|
||||
|
||||
template <class T>
|
||||
class Bitmap {
|
||||
@@ -39,12 +37,18 @@ class Bitmap {
|
||||
Bitmap(uint16_t width, uint16_t height);
|
||||
~Bitmap() = default;
|
||||
|
||||
uint16_t getWidth();
|
||||
uint16_t getHeight();
|
||||
Bitmap(const Bitmap&) = default;
|
||||
Bitmap& operator=(const Bitmap&) = default;
|
||||
Bitmap(Bitmap&&) = default;
|
||||
Bitmap& operator=(Bitmap&&) = default;
|
||||
|
||||
[[nodiscard]] uint16_t getWidth() const;
|
||||
[[nodiscard]] uint16_t getHeight() const;
|
||||
bool setPixels(const std::vector<T>& pixels);
|
||||
std::vector<T> getPixelsCpy();
|
||||
std::optional<std::vector<T>> getLine(uint16_t line);
|
||||
std::optional<std::vector<T>> getCol(uint16_t col);
|
||||
[[nodiscard]] std::vector<T> getPixelsCpy() const;
|
||||
[[nodiscard]] std::vector<T> getLine(uint16_t line) const;
|
||||
[[nodiscard]] std::vector<T> getCol(uint16_t col) const;
|
||||
void visualize() const;
|
||||
|
||||
private:
|
||||
uint16_t mWidth;
|
||||
|
||||
Reference in New Issue
Block a user