@@ -52,13 +52,25 @@ void screenClearCallback(void) {
5252void updateScreenCallback (void ) {}
5353
5454void drawPixelCallback (int16_t x, int16_t y, uint8_t red, uint8_t green, uint8_t blue) {
55- // simple nearest-neighbor scaling
56- int16_t outY = y * activeSeg->height () / gifHeight;
57- int16_t outX = x * activeSeg->width () / gifWidth;
58- // set multiple pixels if upscaling
59- for (int16_t i = 0 ; i < (activeSeg->width ()+(gifWidth-1 )) / gifWidth; i++) {
60- for (int16_t j = 0 ; j < (activeSeg->height ()+(gifHeight-1 )) / gifHeight; j++) {
61- activeSeg->setPixelColorXY (outX + i, outY + j, red, green, blue);
55+ if (activeSeg->height () == 1 ) {
56+ // 1D strip: load pixel-by-pixel left to right, top to bottom (0/0 = top-left in gifs), scale if needed
57+ int totalImgPix = (int )gifWidth * gifHeight;
58+ int stripLen = activeSeg->width ();
59+ if (totalImgPix - stripLen == 1 ) totalImgPix--; // handle off-by-one: skip last pixel instead of first
60+ int start = ((int )y * gifWidth + (int )x) * stripLen / totalImgPix; // simple nearest-neighbor scaling
61+ int end = (((int )y * gifWidth + (int )x+1 ) * stripLen + totalImgPix-1 ) / totalImgPix;
62+ for (int i = start; i < end; i++) {
63+ activeSeg->setPixelColor (i, red, green, blue);
64+ }
65+ } else {
66+ // simple nearest-neighbor scaling
67+ int outY = (int )y * activeSeg->height () / gifHeight;
68+ int outX = (int )x * activeSeg->width () / gifWidth;
69+ // set multiple pixels if upscaling
70+ for (int i = 0 ; i < (activeSeg->width ()+(gifWidth-1 )) / gifWidth; i++) {
71+ for (int j = 0 ; j < (activeSeg->height ()+(gifHeight-1 )) / gifHeight; j++) {
72+ activeSeg->setPixelColorXY (outX + i, outY + j, red, green, blue);
73+ }
6274 }
6375 }
6476}
0 commit comments