Got it almost working...

This commit is contained in:
2023-12-03 22:08:59 +01:00
parent b2971d15dc
commit 4f5af6722e
14 changed files with 143 additions and 78 deletions

View File

@@ -16,12 +16,13 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <cstdint>
#include "graphics/Monochrome.hpp"
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
#define SPDLOG_DEBUG_ON
#define SPDLOG_TRACE_ON
#include "PtouchPrint.hpp"
#include <CLI/App.hpp>
#include <fmt/core.h>
#include <spdlog/common.h>
@@ -38,6 +39,7 @@
#include "CLI/Option.hpp"
#include "P700Printer.hpp"
#include "PtouchPrint.hpp"
#include "graphics/Bitmap.hpp"
#include "graphics/Label.hpp"
#include "libusbwrap/UsbDeviceFactory.hpp"
@@ -93,9 +95,6 @@ int PtouchPrint::run() {
printer->attachUsbDevice(std::move(devices[0]));
auto status = printer->getPrinterStatus();
spdlog::info("Detected tape width is {}mm", status.tapeWidthMm);
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(512, 128);
//printer->printBitmap(bm);
//printer->printText("wurst", 1);
if (0 == mCommands.size()) {
spdlog::warn("No command specified, nothing to do...");
@@ -106,7 +105,15 @@ int PtouchPrint::run() {
SPDLOG_DEBUG("Command: {}", cmd.second);
if (cmd.first == CliCmdType::Text) {
auto label{graphics::Label()};
label.createLabel(cmd.second);
label.create(cmd.second, printer->getPrinterInfo().pixelLines);
auto bm = graphics::Bitmap<graphics::ALPHA8>(label.getLayoutWidth(),
printer->getPrinterInfo().pixelLines);
if (!bm.setPixels(label.getRaw())) {
spdlog::error("Non-matching bitmap size");
return -1;
}
label.writeToPng("salat.png");
printer->printBitmap(bm);
}
}