release 2.0.12 Beta

This commit is contained in:
hyb1996
2017-05-29 20:56:12 +08:00
parent 7c88e578fe
commit 5a79bb577f
13 changed files with 59 additions and 28 deletions

View File

@@ -24,7 +24,7 @@ module.exports = function(__runtime__, scope){
y = region[1] || 0;
width = region[2] || (img.getWidth() - x);
height = region[3] || (img.getHeight() - y);
threads = options.threads || 4;
threads = options.threads || 2;
if(options.threshold !== 0){
threshold = options.threshold || 8;
}
@@ -57,6 +57,8 @@ module.exports = function(__runtime__, scope){
return new com.stardust.autojs.runtime.api.image.ColorDetector.RGBDistanceDetector(color, threshold);
case "equal":
return new com.stardust.autojs.runtime.api.image.ColorDetector.EqualityDetector(color);
case "diff":
return new com.stardust.autojs.runtime.api.image.ColorDetector.DifferenceDetector(color, threshold);
case "rgb+":
return new com.stardust.autojs.runtime.api.image.ColorDetector.WeightedRGBDistanceDetector(color, threshold);
case "hs":

View File

@@ -210,7 +210,6 @@ public class ColorFinder {
Thread thread = Thread.currentThread();
ColorIterator.Pixel pixel = new ColorIterator.Pixel();
while (mResultBox.isNull() && mColorIterator.hasNext() && !thread.isInterrupted()) {
mColorIterator.nextColor(pixel);
mColorIterator.nextColor(pixel);
if (mColorDetector.detectsColor(pixel.red, pixel.green, pixel.blue)) {
mResultBox.set(new Point(mColorIterator.getX(), mColorIterator.getY()));

View File

@@ -111,13 +111,12 @@ public interface ColorIterator {
pixel.red = mByteBuffer.get() & 0xff;
pixel.green = mByteBuffer.get() & 0xff;
pixel.blue = mByteBuffer.get() & 0xff;
mByteBuffer.get();
}
}
/**
* 中心螺旋。未完成。
*/
// TODO: 2017/5/29 中心螺旋。未完成。
class CentralSpiralIterator extends ImageColorIterator {
private static final int DIRECTION_RIGHT = 0;

View File

@@ -25,7 +25,7 @@ public class ScreenCapturer {
private ImageReader mImageReader;
private MediaProjection mMediaProjection;
private VirtualDisplay mVirtualDisplay;
private final Object mImageLock = new Object();
private Image mImage;
public ScreenCapturer(Context context, Intent data, int screenWidth, int screenHeight, int screenDensity) {
MediaProjectionManager manager = (MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
@@ -49,8 +49,11 @@ public class ScreenCapturer {
}
public Image capture() {
Image image = mImageReader.acquireLatestImage();
if (image == null) {
if (mImage != null) {
mImage.close();
}
mImage = mImageReader.acquireLatestImage();
if (mImage == null) {
Looper.prepare();
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
@@ -59,9 +62,9 @@ public class ScreenCapturer {
}
}, null);
Looper.loop();
image = mImageReader.acquireLatestImage();
mImage = mImageReader.acquireLatestImage();
}
return image;
return mImage;
}
@@ -73,5 +76,8 @@ public class ScreenCapturer {
if (mVirtualDisplay != null) {
mVirtualDisplay.release();
}
if (mImage != null) {
mImage.close();
}
}
}