mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-28 23:30:22 -04:00
Revert "Set canvas and costume size to zero if bitmap is empty"
This commit is contained in:
parent
1ba3181a9d
commit
a1db1dd4ac
1 changed files with 4 additions and 10 deletions
|
@ -866,13 +866,10 @@ class VirtualMachine extends EventEmitter {
|
||||||
costume.rotationCenterX = rotationCenterX;
|
costume.rotationCenterX = rotationCenterX;
|
||||||
costume.rotationCenterY = rotationCenterY;
|
costume.rotationCenterY = rotationCenterY;
|
||||||
|
|
||||||
// If the bitmap originally had a zero width or height, use that value
|
|
||||||
const bitmapWidth = bitmap.sourceWidth === 0 ? 0 : bitmap.width;
|
|
||||||
const bitmapHeight = bitmap.sourceHeight === 0 ? 0 : bitmap.height;
|
|
||||||
// @todo: updateBitmapSkin does not take ImageData
|
// @todo: updateBitmapSkin does not take ImageData
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = bitmapWidth;
|
canvas.width = bitmap.width;
|
||||||
canvas.height = bitmapHeight;
|
canvas.height = bitmap.height;
|
||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
context.putImageData(bitmap, 0, 0);
|
context.putImageData(bitmap, 0, 0);
|
||||||
|
|
||||||
|
@ -892,7 +889,7 @@ class VirtualMachine extends EventEmitter {
|
||||||
const storage = this.runtime.storage;
|
const storage = this.runtime.storage;
|
||||||
costume.dataFormat = storage.DataFormat.PNG;
|
costume.dataFormat = storage.DataFormat.PNG;
|
||||||
costume.bitmapResolution = bitmapResolution;
|
costume.bitmapResolution = bitmapResolution;
|
||||||
costume.size = [bitmapWidth, bitmapHeight];
|
costume.size = [bitmap.width, bitmap.height];
|
||||||
costume.asset = storage.createAsset(
|
costume.asset = storage.createAsset(
|
||||||
storage.AssetType.ImageBitmap,
|
storage.AssetType.ImageBitmap,
|
||||||
costume.dataFormat,
|
costume.dataFormat,
|
||||||
|
@ -904,10 +901,7 @@ class VirtualMachine extends EventEmitter {
|
||||||
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
||||||
this.emitTargetsUpdate();
|
this.emitTargetsUpdate();
|
||||||
});
|
});
|
||||||
// Bitmaps with a zero width or height return null for their blob
|
reader.readAsArrayBuffer(blob);
|
||||||
if (blob){
|
|
||||||
reader.readAsArrayBuffer(blob);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue