How to load image to view in RCP?

前端 未结 3 1394
孤独总比滥情好
孤独总比滥情好 2021-01-23 19:03

I am developing an RCP plugin project that includes certain views.First view take employee details like name ,address etc.There is an opt

3条回答
  •  滥情空心
    2021-01-23 19:37

    Following code segment helped me to resolve the above problem.

    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);
    

提交回复
热议问题