如何获得清晰的节点图像 [英] How to get a sharp image of a node

查看:98
本文介绍了如何获得清晰的节点图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码生成节点的图像,并将其与ImageView一起添加到我的场景中:

I use the following code to generate an image of a node and add it with an ImageView to my Scene:

SnapshotParameters snapParams = new SnapshotParameters();
snapParams.setFill(Color.TRANSPARENT);
this.dragImage = new ImageView(draggable.snapshot(snapParams, null));

...

frontPane.getChildren().add(this.dragImage);
Bounds localBounds = frontPane.sceneToLocal(draggable
    .localToScene(draggable.getBoundsInLocal()));
this.dragImage.relocate(localBounds.getMinX(),
localBounds.getMinY());

不幸的是,如我的屏幕截图所示,渲染的图像非常模糊. 任何想法都可能是问题,或如何还原清晰的图像.

Unfortunately, the rendered image is very blurred as can be seen in my screenshot. Any ideas what might be the problem or how to retreive an unblurred image would be welcome.

更新:

在玩我被移除的环绕声时

while playing arround i removed

this.dragImage.relocate(localBounds.getMinX(),localBounds.getMinY());

可产生清晰的图像,完全没有模糊.我不知道为什么会这样,我仍然需要将图像平移到正确的位置.

which results in a sharp image with no blur at all. I have no idea why this is the case and i still need to translate the image to the correct position.

推荐答案

在重定位调用中,我通过简单的强制转换为int摆脱了模糊:

I got rid of the blur with a simple cast to int in the relocate call:

this.dragImage.relocate((int) localBounds.getMinX(),(int) localBounds.getMinY());

我发现localBounds.getMinX()是638.5,而localBounds.getMinY()是136.5.进一步的实验使我得出结论:翻译的非整数值导致图像模糊.

I found that localBounds.getMinX() is 638.5 and localBounds.getMinY() is 136.5. Further experimentation brought me to the conclusion that non integral values for the translation led to the blurred image.

对此的解释可以在

An explanation for this can be found in the API doc for Shape at "Interaction with coordinate systems".

这篇关于如何获得清晰的节点图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆