use TJPGD in flash

This commit is contained in:
philippe44
2022-09-15 13:47:32 -07:00
parent eab321d233
commit 405c7742ef
4 changed files with 45 additions and 35 deletions

View File

@@ -8,7 +8,11 @@
#include <string.h>
#include "math.h"
#ifdef TJPGD_ROM
#include "esp32/rom/tjpgd.h"
#else
#include "tjpgd.h"
#endif
#include "esp_log.h"
#include "gds.h"
@@ -24,7 +28,6 @@ typedef struct {
const unsigned char *InData; // Pointer to jpeg data
int InPos; // Current position in jpeg data
int Width, Height;
uint32_t Pixels;
uint8_t Mode;
union {
void *OutData;
@@ -144,8 +147,6 @@ static unsigned OutHandlerDirect(JDEC *Decoder, void *Bitmap, JRECT *Frame) {
uint8_t *Pixels = (uint8_t*) Bitmap;
int Shift = 8 - Context->Depth;
Context->Pixels += (Frame->bottom - Frame->top + 1) * (Frame->right - Frame->left + 1); \
// decoded image is RGB888, shift only make sense for grayscale
if (Context->Mode == GDS_RGB888) {
OUTHANDLERDIRECT(Scaler888, 0);
@@ -421,11 +422,10 @@ bool GDS_DrawJPEG(struct GDS_Device* Device, uint8_t *Source, int x, int y, int
Context.XMin = x - Context.XOfs;
Context.YMin = y - Context.YOfs;
Context.Mode = Device->Mode;
Context.Pixels = 0;
// do decompress & draw
Res = jd_decomp(&Decoder, OutHandlerDirect, N);
if (Res == JDR_OK && Context.Pixels == Context.Width * Context.Height) {
if (Res == JDR_OK) {
Device->Dirty = true;
Ret = true;
} else {