Skip to content

Commit

Permalink
Cleaned up IVUtil in preparation for multi-library setup
Browse files Browse the repository at this point in the history
Added HEIF/HEIC file extension support
  • Loading branch information
fuelsoft committed Jun 19, 2020
1 parent d0fca03 commit 9db2438
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
44 changes: 36 additions & 8 deletions IVUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ int IVUTIL::formatSupport(std::string extension) {

// sort by first character of extension
switch (extensionUppercase[0]) {
case 'B':
/* BMP */
if (!extensionUppercase.compare("BMP")) return BMP;
break;
case 'G':
/* GIF */
if (!extensionUppercase.compare("GIF")) return GIF;
break;
case 'H':
/* HEIF */
if (!extensionUppercase.compare("HEIF")) return HEIF;
if (!extensionUppercase.compare("HEIC")) return HEIF;
break;
case 'J':
/* JP(E)G */
if (!extensionUppercase.compare("JPG")) return JPG;
Expand All @@ -35,14 +48,6 @@ int IVUTIL::formatSupport(std::string extension) {
/* PNG */
if (!extensionUppercase.compare("PNG")) return PNG;
break;
case 'G':
/* GIF */
if (!extensionUppercase.compare("GIF")) return GIF;
break;
case 'B':
/* BMP */
if (!extensionUppercase.compare("BMP")) return BMP;
break;
case 'T':
/* TIF(F) */
if (!extensionUppercase.compare("TIF")) return TIF;
Expand All @@ -57,6 +62,29 @@ int IVUTIL::formatSupport(std::string extension) {
return -1;
}


/**
* formatSupport - Return library supporting file type
* extension > File extension as String
* return - int < LIB_TYPE_SUPPORT or -1 if unsupported
*/
int IVUTIL::libSupport(std::string extension) {
switch (formatSupport(extension)) {
case BMP:
case JPG:
case PNG:
case TIF:
case TGA:
return TYPE_SDL;
case GIF:
return TYPE_GIFLIB;
case HEIF:
return TYPE_LIBHEIF;
default:
return -1;
}
}

/**
* readSettings - Load settings file if possible and recover window position and size.
*/
Expand Down
11 changes: 10 additions & 1 deletion IVUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ namespace IVUTIL {
GIF,
BMP,
TIF,
TGA
TGA,
HEIF
};

enum LIB_TYPE_SUPPORT {
TYPE_SDL,
TYPE_GIFLIB,
TYPE_LIBHEIF
};

/* Home cooked exception codes */
Expand All @@ -54,6 +61,8 @@ namespace IVUTIL {

int formatSupport(std::string extension);

int libSupport(std::string extension);

void readSettings(std::filesystem::path target, IVSETTINGS* settings);

void writeSettings(std::filesystem::path target, IVSETTINGS* settings);
Expand Down

0 comments on commit 9db2438

Please sign in to comment.