我在数据库中保存了一张图片,将其转换为字节数组传递给一个ImageView进行加载。但是,我无法使它填满整个ImageView。我使用以下代码:
package com.example.AppPrototipo.ui.tourist;
imports...
@Component
public class ExperienceController {
@FXML
Pane imagePane;
@FXML
ImageView imageViewPrincipal;
private final ExperienceRepository experienceRepository;
public ExperienceController(ExperienceRepository experienceRepository) {
this.experienceRepository = experienceRepository;
}
@FXML
private void initialize(){
Experience experience = experienceRepository.findById(1);
Image image = new Image(new ByteArrayInputStream(experience.getImages().get(0).getImageData()));
imageViewPrincipal.setImage(image);
imageViewPrincipal.fitWidthProperty().bind(imagePane.widthProperty());
imageViewPrincipal.fitHeightProperty().bind(imagePane.heightProperty());
}
}
这是我得到的结果:
![imageView中图像未填充右侧](https://istack.dev59.com/wkIIM.webp)