From 85dea70cba8ebf553fc709d39fafbb111bfa20b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Tue, 20 Feb 2018 17:44:53 +0100 Subject: [PATCH] display logo image validation errors on the GUI --- locales/en/messages.json | 6 ++++++ src/js/tabs/osd.js | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 22cc17cd..3c86f417 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -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" }, diff --git a/src/js/tabs/osd.js b/src/js/tabs/osd.js index 1a4098d5..3f12a7ce 100755 --- a/src/js/tabs/osd.js +++ b/src/js/tabs/osd.js @@ -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); }); } });