双向绑定 ImageView 到 byte[]
Bidirectional Binding ImageView to byte[]
我正在尝试在 Imageview 中显示从 byteArray 读取的图像
Image image= new Image(new ByteArrayInputStream(item.getImageBytes()));
imageview.setImage(image);
这工作正常
但我想将图像绑定到 bytearray 之类的
imageview.imageProperty().bind(/*No getting anything what to write here*/);
非常感谢任何帮助。
假设你有这个:
public class Foo {
private final ObjectProperty<byte[]> imageBytes = new SimpleObjectProperty<>();
// Getters and Setters
}
你可以使用这个:
imageview.imageProperty().bind(
Bindings.createObjectBinding(() -> new Image(new ByteArrayInputStream(item.getImageBytes()))
, item.imageBytesProperty()));
我正在尝试在 Imageview 中显示从 byteArray 读取的图像
Image image= new Image(new ByteArrayInputStream(item.getImageBytes()));
imageview.setImage(image);
这工作正常 但我想将图像绑定到 bytearray 之类的
imageview.imageProperty().bind(/*No getting anything what to write here*/);
非常感谢任何帮助。
假设你有这个:
public class Foo {
private final ObjectProperty<byte[]> imageBytes = new SimpleObjectProperty<>();
// Getters and Setters
}
你可以使用这个:
imageview.imageProperty().bind(
Bindings.createObjectBinding(() -> new Image(new ByteArrayInputStream(item.getImageBytes()))
, item.imageBytesProperty()));