Attempt to fix image editing artifacts on Android

This commit is contained in:
JannisX11 2024-02-26 20:10:29 +01:00
parent e3f42f3ef6
commit 5a459111b9
3 changed files with 10 additions and 9 deletions

View File

@ -99,7 +99,7 @@ class TextureLayer {
delete copy.in_limbo;
copy.width = this.width;
copy.height = this.height;
copy.data_url = this.canvas.toDataURL();
copy.data_url = this.canvas.toDataURL('image/png', 1);
return copy;
}
setLimbo() {

View File

@ -1982,7 +1982,7 @@ SharedActions.add('copy', {
Clipbench.image = {
x: offset[0], y: offset[1],
frame: texture.currentFrame,
data: canvas.toDataURL(),
data: canvas.toDataURL('image/png', 1),
}
} else {
let rect = selection.getBoundingRect();
@ -1998,7 +1998,7 @@ SharedActions.add('copy', {
x: rect.start_x,
y: rect.start_y,
frame: texture.currentFrame,
data: copy_canvas.toDataURL()
data: copy_canvas.toDataURL('image/png', 1)
}
canvas = copy_canvas;
}

View File

@ -40,7 +40,8 @@ class Texture {
this.canvas = document.createElement('canvas');
this.canvas.width = this.canvas.height = 16;
this.ctx = this.canvas.getContext('2d', {willReadFrequently: true});
let img = this.img = new Image()
let img = this.img = new Image();
img.setAttribute('pagespeed_no_transform', '');
img.src = 'assets/missing.png'
var tex = new THREE.Texture(this.canvas);
@ -1610,7 +1611,7 @@ class Texture {
}
ctx.putImageData(data, 0, 0);
let dataUrl = canvas.toDataURL('image/png');
let dataUrl = canvas.toDataURL('image/png', 1);
Blockbench.export({
resource_id: 'texture',
@ -1628,7 +1629,7 @@ class Texture {
getDataURL() {
var scope = this;
if (isApp && !scope.internal) {
var dataUrl = this.canvas.toDataURL('image/png');
var dataUrl = this.canvas.toDataURL('image/png', 1);
} else {
var dataUrl = scope.source;
}
@ -1662,7 +1663,7 @@ class Texture {
}
if (update_data_url) {
this.internal = true;
this.source = this.canvas.toDataURL();
this.source = this.canvas.toDataURL('image/png', 1);
this.updateImageFromCanvas();
}
}
@ -1674,7 +1675,7 @@ class Texture {
if (!Format.image_editor) {
this.getMaterial().map.needsUpdate = true;
}
this.source = this.canvas.toDataURL();
this.source = this.canvas.toDataURL('image/png', 1);
this.updateImageFromCanvas();
}
this.saved = false;
@ -2199,7 +2200,7 @@ Clipbench.pasteTextures = function() {
Clipbench.texture = null;
} else if (isApp) {
var image = clipboard.readImage().toDataURL();
var image = clipboard.readImage().toDataURL('image/png', 1);
loadFromDataUrl(image);
} else {
navigator.clipboard.read().then(content => {