drawImageArea method
void
drawImageArea(
- PCanvasImage image,
- int srcX,
- int srcY,
- int srcWidth,
- int srcHeight,
- num dstX,
- num dstY,
- num dstWidth,
- num dstHeight,
override
Draw an image
part (srcX
,srcY
, srcWidth
x srcHeight
) to a
destiny area (dstX
,dstY
, dstWidth
x dstHeight
).
Implementation
@override
void drawImageArea(PCanvasImage image, int srcX, int srcY, int srcWidth,
int srcHeight, num dstX, num dstY, num dstWidth, num dstHeight) {
checkImageLoaded(image);
if (image is! _PCanvasImageFlutter) {
throw ArgumentError(
"Can't handle image type `${image.runtimeType}`: $image");
}
var dstXD = transform.xD(dstX);
var dstYD = transform.yD(dstY);
dstXD = canvasXD(dstXD);
dstYD = canvasYD(dstYD);
final dstWidthD = canvasXD(dstWidth);
final dstHeightD = canvasYD(dstHeight);
final rect1 = Rect.fromLTWH(srcX.toDouble(), srcY.toDouble(),
srcWidth.toDouble(), srcHeight.toDouble());
final rect2 = Rect.fromLTWH(dstXD, dstYD, dstWidthD, dstHeightD);
_widgetPainter.addOp((canvas, size) {
var paint = Paint();
canvas.drawImageRect(image.flutterImage, rect1, rect2, paint);
});
}