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.saveImage = rtImages.saveImage.bind(rtImages);
|
||||||
|
|
||||||
|
images.clip = rtImages.clip.bind(rtImages);
|
||||||
|
|
||||||
images.save = rtImages.saveImage;
|
images.save = rtImages.saveImage;
|
||||||
|
|
||||||
images.pixel = rtImages.pixel;
|
images.pixel = rtImages.pixel;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class Images {
|
|||||||
return mPreCaptureImage;
|
return mPreCaptureImage;
|
||||||
}
|
}
|
||||||
mPreCapture = capture;
|
mPreCapture = capture;
|
||||||
if(mPreCaptureImage != null){
|
if (mPreCaptureImage != null) {
|
||||||
mPreCaptureImage.recycle();
|
mPreCaptureImage.recycle();
|
||||||
}
|
}
|
||||||
mPreCaptureImage = ImageWrapper.ofImage(capture);
|
mPreCaptureImage = ImageWrapper.ofImage(capture);
|
||||||
@@ -132,7 +132,7 @@ public class Images {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int pixel(ImageWrapper image, int x, int y) {
|
public static int pixel(ImageWrapper image, int x, int y) {
|
||||||
if(image == null){
|
if (image == null) {
|
||||||
throw new NullPointerException("image = null");
|
throw new NullPointerException("image = null");
|
||||||
}
|
}
|
||||||
x = ScreenMetrics.rescaleX(x, image.getWidth());
|
x = ScreenMetrics.rescaleX(x, image.getWidth());
|
||||||
@@ -140,6 +140,10 @@ public class Images {
|
|||||||
return image.pixel(x, y);
|
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) {
|
public ImageWrapper read(String path) {
|
||||||
path = mScriptRuntime.files.path(path);
|
path = mScriptRuntime.files.path(path);
|
||||||
|
|||||||
Reference in New Issue
Block a user