display logo image validation errors on the GUI

10.3.x-maintenance
Kiripolszky Károly 2018-02-20 17:44:53 +01:00
parent 41c46afcc5
commit 85dea70cba
2 changed files with 10 additions and 4 deletions

View File

@ -2795,6 +2795,12 @@
"osdSetupReplaceLogoHelp": {
"message": "Customized logo image has to be 288×72 pixels in size containing black and white pixels only on a completely green background."
},
"osdSetupReplaceLogoImageSizeError": {
"message": "Invalid image size; expected $1×$2 instead of $3×$4"
},
"osdSetupReplaceLogoImageColorsError": {
"message": "The image contains an invalid color palette (only green, black and white are allowed)"
},
"osdSetupUploadFont": {
"message": "Upload Font"
},

View File

@ -173,9 +173,8 @@ var openLogoImage = function() {
expectedHeight = FONT.constants.SIZES.CHAR_HEIGHT
* FONT.constants.LOGO.TILES_NUM_VERT;
if (img.width != expectedWidth || img.height != expectedHeight) {
reject("invalid image size; expected "
+ expectedWidth + "×" + expectedHeight + " instead of "
+ img.width + "×" + img.height);
reject(i18n.getMessage("osdSetupReplaceLogoImageSizeError",
[expectedWidth, expectedHeight, img.width, img.height]));
return;
}
var canvas = document.createElement('canvas'),
@ -188,7 +187,7 @@ var openLogoImage = function() {
var rgbPixel = ctx.getImageData(x, y, 1, 1).data.slice(0, 3),
colorKey = rgbPixel.join("-");
if (!FONT.constants.LOGO.MCM_COLORMAP[colorKey]) {
reject("invalid color palette");
reject(i18n.getMessage("osdSetupReplaceLogoImageColorsError"));
return;
}
}
@ -1886,6 +1885,7 @@ TABS.osd.initialize = function (callback) {
FONT.logoPreview($logoPreview);
}).catch(function(error) {
console.error("error loading image:", error);
GUI.log(error);
});
}
});