Skip to content

Commit 9715199

Browse files
committed
small fixes
1 parent 821cdc9 commit 9715199

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

src/graphics/Image/ImageDither.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ uint8_t Image::ditherGetPixelBmp(uint32_t px, int i, int j, int w, bool paletted
4141
px = ditherPalette[px];
4242

4343
if (_inkplate->getDisplayMode() == INKPLATE_1BIT)
44-
px = (uint16_t)px >> 1;
44+
px = (uint16_t)px >> 1;
4545

4646
uint8_t oldPixel = min((uint16_t)0xFF, (uint16_t)((uint16_t)ditherBuffer[0][i] + px));
4747

src/graphics/Image/jpegHelpers/ImageJPEG.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,44 +369,48 @@ bool Image::drawJpegFromBuffer(uint8_t *buff, int32_t len, int x, int y, bool di
369369
* @param int16_t invert
370370
* 1 if using invert, 0 if not
371371
*/
372-
bool Image::drawJpegChunk(int16_t x, int16_t y, uint16_t w, uint16_t h,
373-
uint16_t *bitmap, bool dither, bool invert)
372+
bool Image::drawJpegChunk(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap, bool dither, bool invert)
374373
{
375374
if (!_imagePtrJpeg)
376-
return false;
375+
return 0;
377376

378-
// Carry global error from previous scanline
379377
if (dither && y != _imagePtrJpeg->lastY)
380378
{
381379
_imagePtrJpeg->ditherSwap(E_INK_WIDTH);
382380
_imagePtrJpeg->lastY = y;
383381
}
384382

385-
// --- Draw the JPEG MCU block ---
386383
for (int j = 0; j < h; ++j)
387384
{
388385
for (int i = 0; i < w; ++i)
389386
{
390387
uint32_t rgb = bitmap[j * w + i];
388+
uint32_t val;
389+
391390
uint8_t r = _RED(rgb), g = _GREEN(rgb), b = _BLUE(rgb);
392-
uint32_t val = dither
393-
? _imagePtrJpeg->ditherGetPixelJpeg(RGB8BIT(r, g, b), i, j, x, y, w, h)
394-
: RGB3BIT(r, g, b);
391+
392+
if (dither)
393+
{
394+
val = _imagePtrJpeg->ditherGetPixelJpeg(RGB8BIT(r, g, b), i, j, x, y, w, h);
395+
}
396+
else
397+
{
398+
val = RGB3BIT(r, g, b);
399+
}
395400

396401
if (invert)
397402
val = 7 - val;
403+
if (_imagePtrJpeg->_inkplate->getDisplayMode() == INKPLATE_1BIT)
404+
val = (~val >> 2) & 1;
398405

399406
_imagePtrJpeg->_inkplate->drawPixel(x + i, y + j, val);
400407
}
401408
}
402409

410+
403411
if (dither)
404-
{
405-
// Carry the bottom error row to the global buffer
406412
_imagePtrJpeg->ditherSwapBlockJpeg(x);
407413

408-
}
409-
410-
return true;
414+
return 1;
411415
}
412416
#endif

src/graphics/ImageColor/jpegHelpers/ImageJPEG.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ bool ImageColor::drawJpegChunk(int16_t x, int16_t y, uint16_t w, uint16_t h,
380380
{
381381
_imagePtrJpeg->lastY = y;
382382
}
383-
Serial.println("Gets to drawJPGChunk");
384383

385384
// --- Draw the JPEG MCU block ---
386385
for (int j = 0; j < h; ++j)
@@ -410,14 +409,7 @@ bool ImageColor::drawJpegChunk(int16_t x, int16_t y, uint16_t w, uint16_t h,
410409
_imagePtrJpeg->_inkplate->drawPixel(x + i, y + j, val);
411410
}
412411
}
413-
#ifndef ARDUINO_INKPLATECOLOR
414-
if (dither)
415-
{
416-
// Carry the bottom error row to the global buffer
417-
_imagePtrJpeg->ditherSwapBlockJpeg(x);
418412

419-
}
420-
#endif
421413

422414
return true;
423415
}

0 commit comments

Comments
 (0)