我目前正在开发一个使用 J/Link (MathLink) 的应用程序。但是,我在使用 KernelLink.evaluateToImage() 函数时遇到了一些问题。
我目前的代码是:
byte[] gifData = kl.evaluateToImage("Plot[x,{x,0,1}]",0,0);
if (gifData != null) {
BufferedImage img = ImageIO.read(new ByteArrayInputStream(gifData));
int w = img.getWidth();
int h = img.getHeight();
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
g.drawImage(img, 0, 0, null);
}
else {
System.out.println("Not a valid Graphics Expression.");
}
我总是输入 else 子句,因为 evaluateToImage 总是以某种方式返回 null ......
我启动了内核:
kl = MathLinkFactory.createKernelLink("-linkmode launch -linkname 'math -mathlink'");
你能帮我解决这个问题吗?最好的问候 NikNak