mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
Merge pull request #1081 from fsih/fixBitmapsPlayground
Set the width and height on the canvas used to convert imageData to dataURL
This commit is contained in:
commit
73554f66fe
1 changed files with 5 additions and 3 deletions
|
@ -43,6 +43,7 @@ class Playground extends React.Component {
|
|||
image: svgString, // svg string or data URI
|
||||
rtl: rtl
|
||||
};
|
||||
this.reusableCanvas = document.createElement('canvas');
|
||||
}
|
||||
handleUpdateName (name) {
|
||||
this.setState({name});
|
||||
|
@ -55,11 +56,12 @@ class Playground extends React.Component {
|
|||
} else { // is Bitmap
|
||||
// image parameter has type ImageData
|
||||
// paint editor takes dataURI as input
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
this.reusableCanvas.width = image.width;
|
||||
this.reusableCanvas.height = image.height;
|
||||
const context = this.reusableCanvas.getContext('2d');
|
||||
context.putImageData(image, 0, 0);
|
||||
this.setState({
|
||||
image: canvas.toDataURL('image/png'),
|
||||
image: this.reusableCanvas.toDataURL('image/png'),
|
||||
rotationCenterX: rotationCenterX,
|
||||
rotationCenterY: rotationCenterY
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue