修复 打包项目时无法运行的问题

新增 images.matchTemplate()找图返回多个位置
新增 找图示例
This commit is contained in:
hyb1996
2018-12-16 10:24:57 +08:00
parent 6f66956751
commit 72d8077142
16 changed files with 346 additions and 97 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -0,0 +1,11 @@
var superMario = images.read("./super_mario.jpg");
var block = images.read("./block.png");
var result = images.matchTemplate(superMario, block, {
threshold: 0.8
}).matches;
toastLog(result);
superMario.recycle();
block.recycle();

View File

@@ -0,0 +1,23 @@
var superMario = images.read("./super_mario.jpg");
var block = images.read("./block.png");
var points = images.matchTemplate(superMario, block, {
threshold: 0.8
}).points;
toastLog(points);
var canvas = new Canvas(superMario);
var paint = new Paint();
paint.setColor(colors.parseColor("#2196F3"));
points.forEach(point => {
canvas.drawRect(point.x, point.y, point.x + block.width, point.y + block.height, paint);
});
var image = canvas.toImage();
images.save(image, "/sdcard/tmp.png");
app.viewFile("/sdcard/tmp.png");
superMario.recycle();
block.recycle();
image.recycle();

View File

@@ -0,0 +1,8 @@
var superMario = images.read("./super_mario.jpg");
var mario = images.read("./mario.png");
var point = findImage(superMario, mario);
toastLog(point);
superMario.recycle();
mario.recycle();

View File

@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.regex.Pattern;
import pxb.android.StringItem;
import pxb.android.axml.AxmlWriter;
@@ -201,7 +202,6 @@ public class ApkBuilder {
private void encrypt(File toDir, File file) throws IOException {
FileOutputStream fos = new FileOutputStream(new File(toDir, file.getName()));
EncryptedScriptFileHeader.INSTANCE.writeHeader(fos, (short) new JavaScriptFileSource(file).getExecutionMode());
encrypt(fos, file);
}

View File

@@ -58,6 +58,7 @@ public abstract class Database<M extends BaseModel> {
public Observable<Integer> update(M model) {
return exec(() -> {
ContentValues values = asContentValues(model);
values.put("id", model.getId());
int update = mWritableSQLiteDatabase.update(mTable, values, "id = ?", arg(model.getId()));
if (update >= 1) {
mModelChange.onNext(new ModelChange<>(model, ModelChange.UPDATE));

View File

@@ -21,7 +21,6 @@ public class TimedTaskDatabase extends Database<TimedTask> {
@Override
protected ContentValues asContentValues(TimedTask model) {
ContentValues values = new ContentValues();
values.put("id", model.getId());
values.put("time", model.getTimeFlag());
values.put("scheduled", model.isScheduled());
values.put("delay", model.getDelay());