Added setting for alpha channel faking.

This commit is contained in:
kkapsner 2017-08-11 16:26:24 +02:00
parent 6f9e2ad686
commit 73e4848ffd
5 changed files with 27 additions and 5 deletions

View File

@ -202,6 +202,15 @@
"description": ""
},
"fakeAlphaChannel_title": {
"message": "Alhpa-Kanal auch vortäuschen",
"description": ""
},
"fakeAlphaChannel_description": {
"message": "Aktiviert das Vortäuschen des Alpha-Kanals (Transparenz).",
"description": ""
},
"useCanvasCache_title": {
"message": "Zwischenspeicher für Canvas verwenden",
"description": ""

View File

@ -202,6 +202,15 @@
"description": ""
},
"fakeAlphaChannel_title": {
"message": "Fakt the alpha channel",
"description": ""
},
"fakeAlphaChannel_description": {
"message": "Activates the faking of the alhpa channel (transparency).",
"description": ""
},
"useCanvasCache_title": {
"message": "Use canvas cache",
"description": ""

View File

@ -10,6 +10,7 @@ var settings = {
rng: "nonPersistent",
useCanvasCache: true,
ignoreFrequentColors: 0,
fakeAlphaChannel: false,
persistentRndStorage: "",
storePersistentRnd: false,
askOnlyOnce: true,

View File

@ -77,7 +77,7 @@
}
var rng = randomSupply.getPixelRng(l, window, ignoredColors);
var fakeAlphaChannel = prefs("fakeAlphaChannel");
for (var i = 0; i < l; i += 4){
var [r, g, b, a] = rng(
source[i + 0],
@ -89,13 +89,14 @@
desc[i + 0] = r;
desc[i + 1] = g;
desc[i + 2] = b;
desc[i + 3] = a;
desc[i + 3] = fakeAlphaChannel? a: source[i + 3];
}
var canvas = original.cloneNode(true);
context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
context.putImageData(imageData, 0, 0);
if (prefs("useCanvasCache")){
canvasCache[originalDataURL] = canvas;
canvasCache[canvas.toDataURL()] = canvas;
}
return canvas;
}
@ -373,7 +374,7 @@
ignoredColors = statistic.getMaxColors(prefs("ignoreFrequentColors"));
}
var rng = randomSupply.getPixelRng(l, window, ignoredColors);
var fakeAlphaChannel = prefs("fakeAlphaChannel");
for (var i = 0; i < l; i += 4){
var [r, g, b, a] = rng(
xPixels[i + 0],
@ -385,9 +386,10 @@
xPixels[i + 0] = r;
xPixels[i + 1] = g;
xPixels[i + 2] = b;
xPixels[i + 3] = a;
if (fakeAlphaChannel){
xPixels[i + 3] = a;
}
}
return ret;
}
else {

View File

@ -18,6 +18,7 @@ Version 0.4.0:
* setting to not fake the most frequent colors in a canvas
* setting to enable canvas cache
* setting to hide expert settings
* setting to control if the alpha channel should be faked as wel
fixes:
- ask mode did not work for input types