Rename Image class to Label
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "Image.hpp"
|
||||
#include "graphics/Label.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <spdlog/spdlog.h>
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "pango/pangocairo.h"
|
||||
|
||||
namespace ptprnt::graphics {
|
||||
Image::Image() {
|
||||
Label::Label() {
|
||||
/*mSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 512, 128);
|
||||
cairo_t* cr = cairo_create(mSurface);
|
||||
mFontDescription = pango_font_description_new();
|
||||
@@ -56,16 +56,16 @@ Image::Image() {
|
||||
cairo_surface_write_to_png(mSurface, "hello.png");*/
|
||||
}
|
||||
|
||||
uint8_t* Image::getRaw() {
|
||||
uint8_t* Label::getRaw() {
|
||||
cairo_surface_flush(mSurface);
|
||||
return cairo_image_surface_get_data(mSurface);
|
||||
}
|
||||
|
||||
uint8_t Image::getNumLines(std::string_view strv) {
|
||||
uint8_t Label::getNumLines(std::string_view strv) {
|
||||
return std::count(strv.begin(), strv.end(), '\n');
|
||||
}
|
||||
|
||||
void Image::createLabel(const std::string& str) {
|
||||
void Label::createLabel(const std::string& str) {
|
||||
|
||||
// create Pango layout first, to get the render dimensions
|
||||
auto pangoCtx{pango_font_map_create_context(pango_cairo_font_map_get_default())};
|
||||
@@ -83,7 +83,7 @@ void Image::createLabel(const std::string& str) {
|
||||
|
||||
pango_layout_get_size(pangoLyt, &width, &height);
|
||||
|
||||
spdlog::debug("Layout width: {}, height: {}", width / PANGO_SCALE, height / PANGO_SCALE);
|
||||
SPDLOG_DEBUG("Layout width: {}, height: {}", width / PANGO_SCALE, height / PANGO_SCALE);
|
||||
|
||||
auto surf = cairo_image_surface_create(CAIRO_FORMAT_A8, width / PANGO_SCALE, 128);
|
||||
cairo_t* cr = cairo_create(surf);
|
||||
@@ -95,7 +95,7 @@ void Image::createLabel(const std::string& str) {
|
||||
cairo_surface_write_to_png(surf, "hellow.png");
|
||||
}
|
||||
|
||||
Image::~Image() {
|
||||
spdlog::info("Image dtor...");
|
||||
Label::~Label() {
|
||||
SPDLOG_DEBUG("Image dtor...");
|
||||
}
|
||||
} // namespace ptprnt::graphics
|
@@ -29,15 +29,15 @@ namespace ptprnt::graphics {
|
||||
constexpr const char* DEFAULT_FONT_FAMILY = "sans";
|
||||
constexpr const uint8_t DEFAULT_FONT_SIZE = 32;
|
||||
|
||||
class Image {
|
||||
class Label {
|
||||
public:
|
||||
Image();
|
||||
~Image();
|
||||
Label();
|
||||
~Label();
|
||||
|
||||
Image(const Image&) = delete;
|
||||
Image& operator=(const Image&) = delete;
|
||||
Image(Image&&) = delete;
|
||||
Image& operator=(Image&&) = delete;
|
||||
Label(const Label&) = delete;
|
||||
Label& operator=(const Label&) = delete;
|
||||
Label(Label&&) = delete;
|
||||
Label& operator=(Label&&) = delete;
|
||||
|
||||
uint8_t* getRaw();
|
||||
void createLabel(const std::string& labelText);
|
6
src/graphics/hello.png
Normal file
6
src/graphics/hello.png
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"text" : "Hello, world :)!",
|
||||
"font" : "Liberation Sans",
|
||||
"single-paragraph" : true,
|
||||
"height" : 0
|
||||
}
|
7
src/graphics/hello.txt
Normal file
7
src/graphics/hello.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"text" : " Hello",
|
||||
"font" : "FreeSans 32",
|
||||
"single-paragraph" : true,
|
||||
"alignment" : "center",
|
||||
"height" : 0
|
||||
}
|
0
src/graphics/ptprnt.log
Normal file
0
src/graphics/ptprnt.log
Normal file
Reference in New Issue
Block a user