Skip to content

Commit f48c8e0

Browse files
Laurence BankLaurence Bank
authored andcommitted
Fixed conflicts with PNGDisplay
1 parent 89bdfb0 commit f48c8e0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/JPEGDisplay.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ BB_SPI_LCD *pLCD = (BB_SPI_LCD *)pDraw->pUser;
4444
return 1;
4545
} /* JPEGDraw() */
4646

47-
// Functions to access a file on the SD card
48-
static File myfile;
49-
50-
static void * myOpen(const char *filename, int32_t *size) {
51-
myfile = SD.open(filename);
47+
static void * jpegOpen(const char *filename, int32_t *size) {
48+
static File myfile = SD.open(filename);
5249
*size = myfile.size();
5350
return &myfile;
5451
}
55-
static void myClose(void *handle) {
56-
if (myfile) myfile.close();
52+
static void jpegClose(void *handle) {
53+
File *pFile = (File *)handle;
54+
if (pFile) pFile->close();
5755
}
58-
static int32_t myRead(JPEGFILE *handle, uint8_t *buffer, int32_t length) {
59-
if (!myfile) return 0;
60-
return myfile.read(buffer, length);
56+
static int32_t jpegRead(JPEGFILE *handle, uint8_t *buffer, int32_t length) {
57+
File *pFile = (File *)handle->fHandle;
58+
if (!pFile) return 0;
59+
return pFile->read(buffer, length);
6160
}
62-
static int32_t mySeek(JPEGFILE *handle, int32_t position) {
63-
if (!myfile) return 0;
64-
return myfile.seek(position);
61+
static int32_t jpegSeek(JPEGFILE *handle, int32_t position) {
62+
File *pFile = (File *)handle->fHandle;
63+
if (!pFile) return 0;
64+
return pFile->seek(position);
6565
}
6666

6767
int JPEGDisplay::loadJPEG(BB_SPI_LCD *pLCD, int x, int y, const void *pData, int iDataSize)
@@ -105,7 +105,7 @@ int JPEGDisplay::loadJPEG(BB_SPI_LCD *pLCD, int x, int y, const char *fname)
105105

106106
jpeg = (JPEGDEC *)malloc(sizeof(JPEGDEC));
107107
if (!jpeg) return 0;
108-
if (jpeg->open(fname, myOpen, myClose, myRead, mySeek, JPEGDraw)) {
108+
if (jpeg->open(fname, jpegOpen, jpegClose, jpegRead, jpegSeek, JPEGDraw)) {
109109
jpeg->setPixelType(RGB565_BIG_ENDIAN);
110110
w = jpeg->getWidth();
111111
h = jpeg->getHeight();
@@ -160,7 +160,7 @@ int JPEGDisplay::getJPEGInfo(int *width, int *height, int *bpp, const char *fnam
160160
if (!width || !height || !bpp || !fname) return 0;
161161
jpeg = (JPEGDEC *)malloc(sizeof(JPEGDEC));
162162
if (!jpeg) return 0;
163-
if (jpeg->open(fname, myOpen, myClose, myRead, mySeek, JPEGDraw)) {
163+
if (jpeg->open(fname, jpegOpen, jpegClose, jpegRead, jpegSeek, JPEGDraw)) {
164164
*width = jpeg->getWidth();
165165
*height = jpeg->getHeight();
166166
*bpp = jpeg->getBpp();

0 commit comments

Comments
 (0)