From 0bc64b6c246f9a95898d5c21b0fb30af7efb0938 Mon Sep 17 00:00:00 2001 From: moononournation Date: Mon, 28 Dec 2020 19:42:38 +0800 Subject: [PATCH] Refresh ImgViewerJpeg to use latest JPEGDEC API --- examples/ImgViewerJpeg/JpegClass.h | 39 +++--------------------------- library.properties | 2 +- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/examples/ImgViewerJpeg/JpegClass.h b/examples/ImgViewerJpeg/JpegClass.h index a31508bb..45b79411 100644 --- a/examples/ImgViewerJpeg/JpegClass.h +++ b/examples/ImgViewerJpeg/JpegClass.h @@ -16,8 +16,6 @@ #include #endif -static FS *_fs; - class JpegClass { public: @@ -25,10 +23,11 @@ class JpegClass FS *fs, char *filename, JPEG_DRAW_CALLBACK *jpegDrawCallback, bool useBigEndian, int x, int y, int widthLimit, int heightLimit) { - _fs = fs; - _jpeg.open(filename, JPGOpenFile, JPGCloseFile, JPGReadFile, JPGSeekFile, jpegDrawCallback); + File f = fs->open(filename); + _jpeg.open(f, jpegDrawCallback); // scale to fit height + int _scale; int iMaxMCUs; float ratio = (float)_jpeg.getHeight() / heightLimit; if (ratio <= 1) @@ -61,39 +60,7 @@ class JpegClass } private: - static void *JPGOpenFile(const char *szFilename, int32_t *pFileSize) - { - // Serial.println("JPGOpenFile"); - static File f = _fs->open(szFilename, "r"); - *pFileSize = f.size(); - return &f; - } - - static void JPGCloseFile(void *pHandle) - { - // Serial.println("JPGCloseFile"); - File *f = static_cast(pHandle); - f->close(); - } - - static int32_t JPGReadFile(JPEGFILE *pFile, uint8_t *pBuf, int32_t iLen) - { - // Serial.printf("JPGReadFile, iLen: %d\n", iLen); - File *f = static_cast(pFile->fHandle); - size_t r = f->read(pBuf, iLen); - return r; - } - - static int32_t JPGSeekFile(JPEGFILE *pFile, int32_t iPosition) - { - // Serial.printf("JPGSeekFile, pFile->iPos: %d, iPosition: %d\n", pFile->iPos, iPosition); - File *f = static_cast(pFile->fHandle); - f->seek(iPosition); - return iPosition; - } - JPEGDEC _jpeg; - int _scale = -1; }; #endif // _JPEGCLASS_H_ \ No newline at end of file diff --git a/library.properties b/library.properties index 43b1a897..cfec2b68 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=GFX Library for Arduino -version=1.0.3 +version=1.0.4 author=Moon On Our Nation maintainer=Moon On Our Nation sentence=Arduino graphics library for various displays with various data bus interfaces