From 953c98917742340e9a0aa765744f93fcefd649cb Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 12 Feb 2023 09:39:08 -0600 Subject: [PATCH] Fixign alignment issue on ESP and SAMD boards --- lib/AnimatedGIF/AnimatedGIF_circuitpy.h | 3 ++- lib/AnimatedGIF/gif.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/AnimatedGIF/AnimatedGIF_circuitpy.h b/lib/AnimatedGIF/AnimatedGIF_circuitpy.h index e401935a95..c1f359194f 100644 --- a/lib/AnimatedGIF/AnimatedGIF_circuitpy.h +++ b/lib/AnimatedGIF/AnimatedGIF_circuitpy.h @@ -137,7 +137,8 @@ typedef struct gif_image_tag GIF_CLOSE_CALLBACK *pfnClose; GIFFILE GIFFile; void *pUser; - unsigned char *pFrameBuffer; + //unsigned char *pFrameBuffer; + unsigned int *pFrameBuffer; unsigned char *pPixels, *pOldPixels; unsigned char ucLineBuf[MAX_WIDTH]; // current line unsigned char ucFileBuf[FILE_BUF_SIZE]; // holds temp data and pixel stack diff --git a/lib/AnimatedGIF/gif.c b/lib/AnimatedGIF/gif.c index 00a0137562..0822b608c1 100644 --- a/lib/AnimatedGIF/gif.c +++ b/lib/AnimatedGIF/gif.c @@ -753,7 +753,7 @@ static void DrawNewPixels(GIFIMAGE *pPage, GIFDRAW *pDraw) int x, iPitch = pPage->iCanvasWidth; s = pDraw->pPixels; - d = &pPage->pFrameBuffer[pDraw->iX + (pDraw->y + pDraw->iY) * iPitch]; // dest pointer in our complete canvas buffer + d = (uint8_t*)&pPage->pFrameBuffer[pDraw->iX + (pDraw->y + pDraw->iY) * iPitch]; // dest pointer in our complete canvas buffer if (pDraw->ucDisposalMethod == 2) // restore to background color { memset(d, pDraw->ucBackground, pDraw->iWidth); @@ -785,13 +785,13 @@ static void ConvertNewPixels(GIFIMAGE *pPage, GIFDRAW *pDraw) uint8_t *d, *s; int x; - s = &pPage->pFrameBuffer[(pPage->iCanvasWidth * (pDraw->iY + pDraw->y)) + pDraw->iX]; - d = &pPage->pFrameBuffer[pPage->iCanvasHeight * pPage->iCanvasWidth]; // point past bottom of frame buffer + s = (uint8_t*)&pPage->pFrameBuffer[(pPage->iCanvasWidth * (pDraw->iY + pDraw->y)) + pDraw->iX]; + d = (uint8_t*)&pPage->pFrameBuffer[pPage->iCanvasHeight * pPage->iCanvasWidth]; // point past bottom of frame buffer if (pPage->ucPaletteType == GIF_PALETTE_RGB565_LE || pPage->ucPaletteType == GIF_PALETTE_RGB565_BE) { uint16_t *pPal, *pu16; pPal = (uint16_t *)pDraw->pPalette; - pu16 = (uint16_t *)d; + pu16 = (uint16_t *)&pPage->pFrameBuffer[pPage->iCanvasHeight * pPage->iCanvasWidth]; for (x=0; xiWidth; x++) { *pu16++ = pPal[*s++]; // convert to RGB565 pixels @@ -899,7 +899,7 @@ static void GIFMakePels(GIFIMAGE *pPage, unsigned int code) if (pPage->ucDrawType == GIF_DRAW_COOKED) { ConvertNewPixels(pPage, &gd); // prepare for output - gd.pPixels = &pPage->pFrameBuffer[pPage->iCanvasWidth * pPage->iCanvasHeight]; + gd.pPixels = (uint8_t*)&pPage->pFrameBuffer[pPage->iCanvasWidth * pPage->iCanvasHeight]; } } (*pPage->pfnDraw)(&gd); // callback to handle this line