mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-08 13:42:00 -05:00
Merge pull request #826 from ktbee/fix-empty-bitmap-size
Save the bitmap's height and width on the imageData as sourceHeight or sourceWidth if they are zero (an invalid value for imageData height and width)
This commit is contained in:
commit
a317c26c97
1 changed files with 10 additions and 1 deletions
|
@ -89,9 +89,18 @@ const UpdateImageHOC = function (WrappedComponent) {
|
|||
}
|
||||
}
|
||||
const rect = getHitBounds(plasteredRaster);
|
||||
const imageData = plasteredRaster.getImageData(rect);
|
||||
|
||||
// If the bitmap has a zero width or height, save this information
|
||||
// since zero isn't a valid value for on imageData objects' widths and heights.
|
||||
if (rect.width === 0 || rect.height === 0) {
|
||||
imageData.sourceWidth = rect.width;
|
||||
imageData.sourceHeight = rect.height;
|
||||
}
|
||||
|
||||
this.props.onUpdateImage(
|
||||
false /* isVector */,
|
||||
plasteredRaster.getImageData(rect),
|
||||
imageData,
|
||||
(ART_BOARD_WIDTH / 2) - rect.x,
|
||||
(ART_BOARD_HEIGHT / 2) - rect.y);
|
||||
|
||||
|
|
Loading…
Reference in a new issue