From 0e043b2a1b8eab11ce25ac0fd7ad3a5de8f499b4 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Thu, 6 Nov 2025 15:23:43 +0100 Subject: [PATCH] changed to vWidth/vHeight - since we draw on a segment, we need to use virtual segment dimensions or scaling will be off when using any virtualisation like grouping/spacing/mirror etc. --- wled00/image_loader.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wled00/image_loader.cpp b/wled00/image_loader.cpp index 599c528e..a72babd4 100644 --- a/wled00/image_loader.cpp +++ b/wled00/image_loader.cpp @@ -55,7 +55,7 @@ void drawPixelCallback(int16_t x, int16_t y, uint8_t red, uint8_t green, uint8_t if (activeSeg->height() == 1) { // 1D strip: load pixel-by-pixel left to right, top to bottom (0/0 = top-left in gifs), scale if needed int totalImgPix = (int)gifWidth * gifHeight; - int stripLen = activeSeg->width(); + int stripLen = activeSeg->vWidth(); if (totalImgPix - stripLen == 1) totalImgPix--; // handle off-by-one: skip last pixel instead of first int start = ((int)y * gifWidth + (int)x) * stripLen / totalImgPix; // simple nearest-neighbor scaling int end = (((int)y * gifWidth + (int)x+1) * stripLen + totalImgPix-1) / totalImgPix; @@ -64,11 +64,11 @@ void drawPixelCallback(int16_t x, int16_t y, uint8_t red, uint8_t green, uint8_t } } else { // simple nearest-neighbor scaling - int outY = (int)y * activeSeg->height() / gifHeight; - int outX = (int)x * activeSeg->width() / gifWidth; + int outY = (int)y * activeSeg->vHeight() / gifHeight; + int outX = (int)x * activeSeg->vWidth() / gifWidth; // set multiple pixels if upscaling - for (int i = 0; i < (activeSeg->width()+(gifWidth-1)) / gifWidth; i++) { - for (int j = 0; j < (activeSeg->height()+(gifHeight-1)) / gifHeight; j++) { + for (int i = 0; i < (activeSeg->vWidth()+(gifWidth-1)) / gifWidth; i++) { + for (int j = 0; j < (activeSeg->vHeight()+(gifHeight-1)) / gifHeight; j++) { activeSeg->setPixelColorXY(outX + i, outY + j, red, green, blue); } }