examples: ignore loading raw image file.

in the last commit, it added a raw image file in the images folder.
It breaks Multicanvas, Svg which try to load all kinds of files in it.

We don't need to load all files by figuring out file extension name.
This commit is contained in:
Hermet Park 2020-11-23 18:33:10 +09:00 committed by Hermet Park
parent e00f948705
commit b125a7ea2e
2 changed files with 9 additions and 1 deletions

View file

@ -84,6 +84,10 @@ void drawSwView(void* data, Eo* obj)
void tvgSwTest(const char* name, const char* path, void* data) void tvgSwTest(const char* name, const char* path, void* data)
{ {
//ignore if not svgs.
const char *ext = name + strlen(name) - 3;
if (strcmp(ext, "svg")) return;
Eo* win = (Eo*) data; Eo* win = (Eo*) data;
uint32_t* buffer = (uint32_t*) calloc(sizeof(uint32_t), SIZE * SIZE); uint32_t* buffer = (uint32_t*) calloc(sizeof(uint32_t), SIZE * SIZE);
@ -106,7 +110,7 @@ void tvgSwTest(const char* name, const char* path, void* data)
tvgDrawCmds(canvas.get(), path, name); tvgDrawCmds(canvas.get(), path, name);
canvases.push_back(move(canvas)); canvases.push_back(move(canvas));
} }

View file

@ -14,6 +14,10 @@ static std::vector<unique_ptr<tvg::Picture>> pictures;
void svgDirCallback(const char* name, const char* path, void* data) void svgDirCallback(const char* name, const char* path, void* data)
{ {
//ignore if not svgs.
const char *ext = name + strlen(name) - 3;
if (strcmp(ext, "svg")) return;
auto picture = tvg::Picture::gen(); auto picture = tvg::Picture::gen();
char buf[PATH_MAX]; char buf[PATH_MAX];