mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-10 12:31:21 -04:00
Merge a1db1dd4ac
into f207757ef0
This commit is contained in:
commit
420a57099f
1 changed files with 4 additions and 10 deletions
|
@ -900,13 +900,10 @@ class VirtualMachine extends EventEmitter {
|
|||
costume.rotationCenterX = rotationCenterX;
|
||||
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
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = bitmapWidth;
|
||||
canvas.height = bitmapHeight;
|
||||
canvas.width = bitmap.width;
|
||||
canvas.height = bitmap.height;
|
||||
const context = canvas.getContext('2d');
|
||||
context.putImageData(bitmap, 0, 0);
|
||||
|
||||
|
@ -926,7 +923,7 @@ class VirtualMachine extends EventEmitter {
|
|||
const storage = this.runtime.storage;
|
||||
costume.dataFormat = storage.DataFormat.PNG;
|
||||
costume.bitmapResolution = bitmapResolution;
|
||||
costume.size = [bitmapWidth, bitmapHeight];
|
||||
costume.size = [bitmap.width, bitmap.height];
|
||||
costume.asset = storage.createAsset(
|
||||
storage.AssetType.ImageBitmap,
|
||||
costume.dataFormat,
|
||||
|
@ -938,10 +935,7 @@ class VirtualMachine extends EventEmitter {
|
|||
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
||||
this.emitTargetsUpdate();
|
||||
});
|
||||
// Bitmaps with a zero width or height return null for their blob
|
||||
if (blob){
|
||||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
reader.readAsArrayBuffer(blob);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue