问题描述
我尝试使用图像作为素材在 Box 上显示图像,但发现显示在框上的图像模糊。
下面的代码显示了 Box 上的图像(模糊)与 ImageView 节点中按预期显示的相同图像之间的差异。
这是为什么?
package com.mycompany.testg;
import java.io.IOException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.phongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.scene.paint.Color;
import javafx.scene.layout.VBox;
/**
* JavaFX App
*/
public class App extends Application {
String img = "https://image.flaticon.com/icons/png/512/741/741485.png";
@Override
public void start(Stage stage) throws IOException {
Group grp = new Group();
Box bx = new Box(512,512,1);
phongMaterial mat = new phongMaterial();
mat.setDiffuseMap(new Image(img));
bx.setMaterial(mat);
bx.setTranslateX(256);
bx.setTranslateY(256);
bx.setTranslateZ(0);
ImageView iv = new ImageView(img);
iv.setTranslateX(555);
iv.setTranslateY(0);
iv.setTranslateZ(0);
grp.getChildren().addAll(bx,iv);
Scene scene = new Scene(grp,1100,600,true);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)