From e4d554dc661bac0b50d972c958ffed905e4725d1 Mon Sep 17 00:00:00 2001 From: moononournation Date: Thu, 8 Feb 2024 17:55:54 +0800 Subject: [PATCH] #434 --- src/canvas/Arduino_Canvas_3bit.cpp | 1 + src/canvas/Arduino_Canvas_Mono.cpp | 27 ++------------------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/canvas/Arduino_Canvas_3bit.cpp b/src/canvas/Arduino_Canvas_3bit.cpp index 875aa573..a6d73d3d 100644 --- a/src/canvas/Arduino_Canvas_3bit.cpp +++ b/src/canvas/Arduino_Canvas_3bit.cpp @@ -7,6 +7,7 @@ Arduino_Canvas_3bit::Arduino_Canvas_3bit(int16_t w, int16_t h, Arduino_G *output, int16_t output_x, int16_t output_y) : Arduino_GFX(w, h), _output(output), _output_x(output_x), _output_y(output_y) { + setRotation(0); } Arduino_Canvas_3bit::~Arduino_Canvas_3bit() diff --git a/src/canvas/Arduino_Canvas_Mono.cpp b/src/canvas/Arduino_Canvas_Mono.cpp index 1ce99e83..b187dde7 100644 --- a/src/canvas/Arduino_Canvas_Mono.cpp +++ b/src/canvas/Arduino_Canvas_Mono.cpp @@ -8,6 +8,7 @@ Arduino_Canvas_Mono::Arduino_Canvas_Mono(int16_t w, int16_t h, Arduino_G *output : Arduino_GFX(w, h), _output(output), _output_x(output_x), _output_y(output_y), _verticalByte(verticalByte), _canvas_width(w), _canvas_height(h) { + setRotation(0); } Arduino_Canvas_Mono::~Arduino_Canvas_Mono() @@ -68,30 +69,6 @@ bool Arduino_Canvas_Mono::begin(int32_t speed) void Arduino_Canvas_Mono::writePixelPreclipped(int16_t x, int16_t y, uint16_t color) { - // rotate to the orientation in the bitmap buffer - if (_rotation) - { - int16_t tmp; - - switch (_rotation) - { - case 1: // 90° right - tmp = y; - y = x; - x = _canvas_width - 1 - tmp; - break; - case 2: // 180° - x = _canvas_width - 1 - x; - y = _canvas_height - 1 - y; - break; - case 3: // 270° right == 90° left - tmp = y; - y = _canvas_height - 1 - x; - x = tmp; - break; - } - } - // change the pixel in the original orientation of the bitmap buffer if (_verticalByte) { @@ -111,7 +88,7 @@ void Arduino_Canvas_Mono::writePixelPreclipped(int16_t x, int16_t y, uint16_t co { // horizontal buffer layout: 1 byte in the buffer contains 8 horizontal pixels int16_t w = (_canvas_width + 7) / 8; - int32_t pos = y * w + x / 8; + int32_t pos = (y * w) + (x / 8); if (color & 0b1000010000010000) {