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:
Katie Broida 2019-04-16 14:48:04 -04:00 committed by GitHub
commit a317c26c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);