Skip to content

Commit

Permalink
修复 打包项目时无法运行的问题
Browse files Browse the repository at this point in the history
新增 images.matchTemplate()找图返回多个位置
新增 找图示例
  • Loading branch information
hyb1996 committed Dec 16, 2018
1 parent 6f66956 commit 72d8077
Show file tree
Hide file tree
Showing 16 changed files with 346 additions and 97 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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();
Original file line number Diff line number Diff line change
@@ -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();
Original file line number Diff line number Diff line change
@@ -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();
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -201,7 +202,6 @@ public void copyDir(String relativePath, String path) throws IOException {

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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public Observable<Integer> delete(M model) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public TimedTaskDatabase(Context context) {
@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());
Expand Down
Loading

0 comments on commit 72d8077

Please sign in to comment.