我正在开发一个RCP plugin project
其中包括某些视图。第一个视图
员工详细信息,例如name
,address
等等。有一个选项可以使用浏览按钮上传员工图像。第二个视图显示在第一个视图中输入的详细信息。除照片之外的所有详细信息都显示良好。
它在照片标签的位置显示一个红色方块。我设置照片的代码如下所示:
Label photoLabel = new Label(parent, SWT.NONE);
photoLabel.setBounds(420, 233, 100, 106);
photoLabel.setImage(SWTResourceManager.getImage(FormDataViewClass.class,photoUploadPath));
where photoUploadPath
是包含上传照片路径的字符串变量。
我该如何解决这个问题?
以下代码段帮助我解决了上述问题。
byte[] uploadedImg = null;
try {
File f1 = new File(photoUploadPath);
double fileLen = f1.length();
uploadedImg = new byte[(int) fileLen];
FileInputStream inputStream = new FileInputStream(photoUploadPath);
int nRead = 0;
while ((nRead = inputStream.read(uploadedImg)) != -1) {
System.out.println("!!!!!!!!!!!!!!!!!" + new String(uploadedImg));
}
inputStream.close();
} catch (Exception e2) {
// TODO: handle exception
}
BufferedInputStream inputStreamReader = new BufferedInputStream(new ByteArrayInputStream(uploadedImg));
ImageData imageData = new ImageData(inputStreamReader);
Image image = new Image(Display.getCurrent(), imageData);
photoLabel.setImage(image);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)