0

I am trying to load an image from a user selected input file and show it to the user using a Label. This image is a property of the selected TreeViewer node. So when selection changes the image (if exists) should be changed as well. (Master/Detail scenario)

The forum post How to load image to view in RCP? suggests that I have to manually read the image as a byte array.

Is there framework provided way to load and display images directly? Also if such a way exists what do I have to do to replace the image with a new one when selection changes? so that there is only one image in memory at a time.

Community
  • 1
  • 1
Jehan Zeb
  • 155
  • 12

1 Answers1

1

To read an image use:

ImageDescriptor desc = ImageDescriptor.createFromFile(null, "file path");

Image image = desc.createImage();

don't forget the dispose of the image when you are done with it.

greg-449
  • 109,219
  • 232
  • 102
  • 145