feat: #275 images.clip()
This commit is contained in:
@@ -32,6 +32,8 @@ module.exports = function(__runtime__, scope){
|
||||
|
||||
images.saveImage = rtImages.saveImage.bind(rtImages);
|
||||
|
||||
images.clip = rtImages.clip.bind(rtImages);
|
||||
|
||||
images.save = rtImages.saveImage;
|
||||
|
||||
images.pixel = rtImages.pixel;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Images {
|
||||
return mPreCaptureImage;
|
||||
}
|
||||
mPreCapture = capture;
|
||||
if(mPreCaptureImage != null){
|
||||
if (mPreCaptureImage != null) {
|
||||
mPreCaptureImage.recycle();
|
||||
}
|
||||
mPreCaptureImage = ImageWrapper.ofImage(capture);
|
||||
@@ -132,7 +132,7 @@ public class Images {
|
||||
}
|
||||
|
||||
public static int pixel(ImageWrapper image, int x, int y) {
|
||||
if(image == null){
|
||||
if (image == null) {
|
||||
throw new NullPointerException("image = null");
|
||||
}
|
||||
x = ScreenMetrics.rescaleX(x, image.getWidth());
|
||||
@@ -140,6 +140,10 @@ public class Images {
|
||||
return image.pixel(x, y);
|
||||
}
|
||||
|
||||
public ImageWrapper clip(ImageWrapper img, int x, int y, int w, int h) {
|
||||
return ImageWrapper.ofBitmap(Bitmap.createBitmap(img.getBitmap(), x, y, w, h));
|
||||
}
|
||||
|
||||
|
||||
public ImageWrapper read(String path) {
|
||||
path = mScriptRuntime.files.path(path);
|
||||
|
||||
Reference in New Issue
Block a user