diff --git a/luqj-damo/src/main/java/com/luqj/dm/test/JacobDemo.java b/luqj-damo/src/main/java/com/luqj/dm/test/JacobDemo.java index 3c5c267..7d8d79e 100644 --- a/luqj-damo/src/main/java/com/luqj/dm/test/JacobDemo.java +++ b/luqj-damo/src/main/java/com/luqj/dm/test/JacobDemo.java @@ -3,6 +3,7 @@ package com.luqj.dm.test; import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; import com.jacob.com.Variant; +import com.luqj.damo.obj.DmSoft; import com.sun.jna.*; import java.io.IOException; @@ -26,7 +27,6 @@ public class JacobDemo { // 对应 DLL 方法,两个参数 int SetDllPathA(String path, int is64); } - public static void main(String[] args) throws IOException { // 指定 DLL 搜索路径 NativeLibrary.addSearchPath("DmReg", "D:\\myprojects\\myEpusdt\\luqj-damo\\libs"); @@ -37,6 +37,42 @@ public class JacobDemo { // 调用 SetDllPathA int result = INSTANCE.SetDllPathA(dllPath, 0); + if (result == 1) { + System.out.println("设置成功"); + } else { + System.out.println("设置失败,返回值:" + result); + } + DmSoft dmSoft = new DmSoft(); + System.out.println(dmSoft.ver()); + + // 1. 读取 JPG + BufferedImage image = png2bmp("D:/myprojects/myEpusdt/luqj-damo/src/main/resources/1.png"); + // 2. 写入内存 BMP + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageIO.write(image, "BMP", baos); + byte[] bmpBytes = baos.toByteArray(); + baos.close(); + mem.write(0, bmpBytes, 0, bmpBytes.length); + String param = "mem:" + Pointer.nativeValue(mem) + "," + bmpBytes.length; + dmSoft.setDisplayInput(param); + dmSoft.setPath("D:\\myprojects\\myEpusdt\\luqj-damo\\src\\main\\resources"); + int[] x = new int[1]; + int[] y = new int[1]; + int ret = dmSoft.findPic(0, 0, 703, 319, "2.bmp", "000000", 0.9, 0, x, y); + System.out.println("返回值: " + ret); + System.out.println("X: " + x[0]); + System.out.println("Y: " + y[0]); + } + public static void main1(String[] args) throws IOException { + // 指定 DLL 搜索路径 + NativeLibrary.addSearchPath("DmReg", "D:\\myprojects\\myEpusdt\\luqj-damo\\libs"); + DmReg INSTANCE = Native.load("DmReg", DmReg.class); + // DLL 路径,比如 C:\DmSoft + String dllPath = "C:\\Users\\Administrator\\Desktop\\dm\\dm.dll"; + + // 调用 SetDllPathA + int result = INSTANCE.SetDllPathA(dllPath, 0); + if (result == 1) { System.out.println("设置成功"); } else {