我目前正在开发一个使用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.");
}我总是输入-子句,因为evaluateToImage总是返回null.
我发布内核时:
kl = MathLinkFactory.createKernelLink("-linkmode launch -linkname 'math -mathlink'");你能帮我解决这个问题吗?向NikNak问好
发布于 2014-09-06 12:11:57
解决方案是使用evaluateToTypeset()函数。正确的代码必须是:
byte[] gifData = mathLink.evaluateToTypeset(mathInput, 0, true);
FileOutputStream fileStream = new FileOutputStream(new File("/../1.gif"));
fileStream.write(gifData);
fileStream.close();https://stackoverflow.com/questions/25577295
复制相似问题