crop method
Implementation
UGrayImage crop(int x, int y, int w, int h) {
final int cx = x.clamp(0, width);
final int cy = y.clamp(0, height);
final int cw = w.clamp(0, width - cx);
final int ch = h.clamp(0, height - cy);
final Uint8List out = Uint8List(cw * ch);
for (int row = 0; row < ch; row++) {
final int src = (cy + row) * stride + cx;
out.setRange(row * cw, row * cw + cw, data, src);
}
return UGrayImage(out, cw, ch, left: left + cx, top: top + cy, sourceWidth: sourceWidth == 0 ? width : sourceWidth, sourceHeight: sourceHeight == 0 ? height : sourceHeight);
}