Skip to content

Commit 53ac98b

Browse files
committed
webp image support
#273
1 parent 554d4ec commit 53ac98b

File tree

359 files changed

+129328
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

359 files changed

+129328
-93
lines changed

lib/FileMgrService/library.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"name": "TopicHandlerService"
2020
}, {
2121
"name": "Utilities"
22+
}, {
23+
"name": "YAWidgets"
2224
}],
2325
"frameworks": "*",
2426
"platforms": "*"

lib/FileMgrService/src/FileMgrService.cpp

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <SettingsService.h>
4242
#include <TopicHandlerService.h>
4343
#include <JsonFile.h>
44+
#include <BitmapWidget.h>
4445

4546
/******************************************************************************
4647
* Compiler Switches
@@ -69,10 +70,6 @@ const char* FileMgrService::ENTITY_ID = "fileMgrService";
6970
const char* FileMgrService::TOPIC_FILES = "files";
7071
const char* FileMgrService::TOPIC_UPLOAD = "upload";
7172
const char* FileMgrService::TOPIC_REMOVE = "remove";
72-
const char* FileMgrService::FILE_EXTENSIONS[] = {
73-
".bmp",
74-
".gif"
75-
};
7673

7774
/******************************************************************************
7875
* Public Methods
@@ -130,7 +127,7 @@ bool FileMgrService::start()
130127
}
131128

132129
/* Add new files to file table. */
133-
if (true == scanForFiles(m_fileTable, FILE_EXTENSIONS, UTIL_ARRAY_NUM(FILE_EXTENSIONS)))
130+
if (true == scanForFiles(m_fileTable, BitmapWidget::IMAGE_FILE_EXTENSIONS, BitmapWidget::IMAGE_FILE_EXTENSIONS_COUNT))
134131
{
135132
m_hasFileTableChanged = true;
136133
m_isDirty = true;
@@ -467,30 +464,14 @@ bool FileMgrService::isUploadAccepted(const String& topic, const String& srcFile
467464

468465
if (true == topic.equals(TOPIC_UPLOAD))
469466
{
470-
size_t idx;
471-
472467
/* Accept only files with the right file extension. */
473-
for (idx = 0U; idx < UTIL_ARRAY_NUM(FILE_EXTENSIONS); ++idx)
474-
{
475-
int32_t fileExtIdx = srcFilename.lastIndexOf(".");
476-
477-
if (0 <= fileExtIdx)
478-
{
479-
String fileExt = srcFilename.substring(fileExtIdx);
480-
481-
if (true == fileExt.equalsIgnoreCase(FILE_EXTENSIONS[idx]))
482-
{
483-
isAccepted = true;
484-
break;
485-
}
486-
}
487-
}
488-
489-
if (true == isAccepted)
468+
if (true == BitmapWidget::isImageTypeSupported(srcFilename))
490469
{
491470
dstFilename = WORKING_DIRECTORY;
492471
dstFilename += "/";
493472
dstFilename += srcFilename;
473+
474+
isAccepted = true;
494475
}
495476
}
496477

lib/FileMgrService/src/FileMgrService.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ class FileMgrService : public IService
193193
*/
194194
static const char* TOPIC_REMOVE;
195195

196-
/**
197-
* Supported file extensions.
198-
*/
199-
static const char* FILE_EXTENSIONS[];
200-
201196
/**
202197
* Timer period in ms to check whether the file table is dirty and needs
203198
* to be saved to the configuration file.

lib/YAWidgets/library.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"name": "Fonts"
2424
}, {
2525
"name": "Utilities"
26+
}, {
27+
"name": "libwebp"
2628
}],
2729
"frameworks": "*",
2830
"platforms": "*"

lib/YAWidgets/src/GifImgPlayer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
*****************************************************************************/
3636
#include "GifImgPlayer.h"
3737
#include "LzwDecoder.h"
38-
#include "GifFileLoader.h"
39-
#include "GifFileToMemLoader.h"
4038
#include <Logging.h>
4139
#include <TypedAllocator.hpp>
4240

@@ -372,7 +370,7 @@ GifImgPlayer& GifImgPlayer::operator=(const GifImgPlayer& player)
372370
return *this;
373371
}
374372

375-
GifImgPlayer::Ret GifImgPlayer::open(FS& fs, const String& fileName, IGifLoader& loader)
373+
GifImgPlayer::Ret GifImgPlayer::open(FS& fs, const String& fileName, IImageLoader& loader)
376374
{
377375
Ret ret = RET_OK;
378376

lib/YAWidgets/src/GifImgPlayer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include <YAGfxCanvas.h>
5050
#include <YAGfxBitmap.h>
5151
#include <SimpleTimer.hpp>
52-
#include <IGifLoader.h>
52+
#include <IImageLoader.h>
5353
#include <TypedAllocator.hpp>
5454
#include <PsAllocator.hpp>
5555

@@ -131,11 +131,11 @@ class GifImgPlayer
131131
*
132132
* @param[in] fs Filesystem to use
133133
* @param[in] fileName Name of the GIF file.
134-
* @param[in] loader GIF file loader to use.
134+
* @param[in] loader Image file loader to use.
135135
*
136136
* @return Status informtion
137137
*/
138-
Ret open(FS& fs, const String& fileName, IGifLoader& loader);
138+
Ret open(FS& fs, const String& fileName, IImageLoader& loader);
139139

140140
/**
141141
* Close the GIF file.
@@ -236,7 +236,7 @@ class GifImgPlayer
236236
PaletteColorAllocator m_paletteColorAllocator; /**< Palette color allocator. */
237237
DataAllocator m_dataAllocator; /**< uint8_t allocator. */
238238
YAGfxDynamicBitmap m_bitmap; /**< The bitmap contains the last drawn scene. */
239-
IGifLoader* m_gifLoader; /**< GIF file loader used to read the file. */
239+
IImageLoader* m_gifLoader; /**< GIF file loader used to read the file. */
240240
YAGfxCanvas m_canvas; /**< Canvas used for drawing each scene. Its position and size follows the image descriptor. */
241241
uint8_t m_bgColorIndex; /**< Background color index. Used by disposal method. */
242242
PaletteColor* m_globalColorTable; /**< Global color table. */
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
DESCRIPTION
2626
*******************************************************************************/
2727
/**
28-
* @file IGifLoader.h
29-
* @brief Interface of GIF loader
28+
* @file IImageLoader.h
29+
* @brief Interface of image loader
3030
* @author Andreas Merkle <[email protected]>
3131
*
3232
* @addtogroup GFX
3333
*
3434
* @{
3535
*/
3636

37-
#ifndef IGIFLOADER_H
38-
#define IGIFLOADER_H
37+
#ifndef IIMAGELOADER_H
38+
#define IIMAGELOADER_H
3939

4040
/******************************************************************************
4141
* Compile Switches
@@ -57,36 +57,36 @@
5757
*****************************************************************************/
5858

5959
/**
60-
* Interface for GIF file loader.
60+
* Interface for image file loader.
6161
*/
62-
class IGifLoader
62+
class IImageLoader
6363
{
6464
public:
6565

6666
/**
6767
* Destroy the interface.
6868
*/
69-
virtual ~IGifLoader()
69+
virtual ~IImageLoader()
7070
{
7171
}
7272

7373
/**
74-
* Open a GIF file.
74+
* Open an image file.
7575
*
7676
* @param[in] fs Filesystem to use
77-
* @param[in] fileName Name of the GIF file.
77+
* @param[in] fileName Name of the image file.
7878
*
7979
* @return If successful, it will return true otherwise false.
8080
*/
8181
virtual bool open(FS& fs, const String& fileName) = 0;
8282

8383
/**
84-
* Close the GIF file.
84+
* Close the image file.
8585
*/
8686
virtual void close() = 0;
8787

8888
/**
89-
* Read data from GIF.
89+
* Read data from image.
9090
*
9191
* @param[in] buffer Buffer to fill.
9292
* @param[in] size Buffer size in bytes.
@@ -124,7 +124,7 @@ class IGifLoader
124124
/**
125125
* Construct the interface.
126126
*/
127-
IGifLoader()
127+
IImageLoader()
128128
{
129129
}
130130
};
@@ -133,6 +133,6 @@ class IGifLoader
133133
* Functions
134134
*****************************************************************************/
135135

136-
#endif /* IGIFLOADER_H */
136+
#endif /* IIMAGELOADER_H */
137137

138138
/** @} */
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
DESCRIPTION
2626
*******************************************************************************/
2727
/**
28-
* @file GifFileLoader.h
29-
* @brief GIF file loader
28+
* @file ImageFileLoader.h
29+
* @brief Image file loader
3030
* @author Andreas Merkle <[email protected]>
3131
*
3232
* @addtogroup GFX
3333
*
3434
* @{
3535
*/
3636

37-
#ifndef GIF_FILE_LOADER_H
38-
#define GIF_FILE_LOADER_H
37+
#ifndef IMAGE_FILE_LOADER_H
38+
#define IMAGE_FILE_LOADER_H
3939

4040
/******************************************************************************
4141
* Compile Switches
@@ -44,7 +44,7 @@
4444
/******************************************************************************
4545
* Includes
4646
*****************************************************************************/
47-
#include "IGifLoader.h"
47+
#include "IImageLoader.h"
4848

4949
/******************************************************************************
5050
* Macros
@@ -55,48 +55,48 @@
5555
*****************************************************************************/
5656

5757
/**
58-
* GIF file loader.
58+
* Image file loader.
5959
*/
60-
class GifFileLoader : public IGifLoader
60+
class ImageFileLoader : public IImageLoader
6161
{
6262
public:
6363

6464
/**
65-
* Construct the GIF file loader.
65+
* Construct the image file loader.
6666
*/
67-
GifFileLoader() :
68-
IGifLoader(),
67+
ImageFileLoader() :
68+
IImageLoader(),
6969
m_fd()
7070
{
7171
}
7272

7373
/**
74-
* Construct the GIF file loader by copy.
74+
* Construct the image file loader by copy.
7575
*
76-
* @param[in] loader GIF file loader to copy.
76+
* @param[in] loader Image file loader to copy.
7777
*/
78-
GifFileLoader(const GifFileLoader& loader) :
79-
IGifLoader(),
78+
ImageFileLoader(const ImageFileLoader& loader) :
79+
IImageLoader(),
8080
m_fd(loader.m_fd)
8181
{
8282
}
8383

8484
/**
85-
* Destroy the GIF file loader.
85+
* Destroy the image file loader.
8686
*/
87-
~GifFileLoader() override
87+
~ImageFileLoader() override
8888
{
8989
close();
9090
}
9191

9292
/**
9393
* Assignment operator.
9494
*
95-
* @param[in] loader GIF file loader to copy.
95+
* @param[in] loader Image file loader to copy.
9696
*
9797
* @return Reference to this loader.
9898
*/
99-
GifFileLoader& operator=(const GifFileLoader& loader)
99+
ImageFileLoader& operator=(const ImageFileLoader& loader)
100100
{
101101
if (this != &loader)
102102
{
@@ -109,10 +109,10 @@ class GifFileLoader : public IGifLoader
109109
}
110110

111111
/**
112-
* Open a GIF file.
112+
* Open an image file.
113113
*
114114
* @param[in] fs Filesystem to use.
115-
* @param[in] fileName Name of the GIF file.
115+
* @param[in] fileName Name of the image file.
116116
*
117117
* @return If successful, it will return true otherwise false.
118118
*/
@@ -131,7 +131,7 @@ class GifFileLoader : public IGifLoader
131131
}
132132

133133
/**
134-
* Close the GIF file.
134+
* Close the image file.
135135
*/
136136
void close() final
137137
{
@@ -142,7 +142,7 @@ class GifFileLoader : public IGifLoader
142142
}
143143

144144
/**
145-
* Read data from GIF.
145+
* Read data from image.
146146
*
147147
* @param[in] buffer Buffer to fill.
148148
* @param[in] size Buffer size in bytes.
@@ -208,6 +208,6 @@ class GifFileLoader : public IGifLoader
208208
* Functions
209209
*****************************************************************************/
210210

211-
#endif /* GIF_FILE_LOADER_H */
211+
#endif /* IMAGE_FILE_LOADER_H */
212212

213213
/** @} */

0 commit comments

Comments
 (0)