I have an image and I want to get pixel color from image. Something like this:
image.getPixel(100,100).Color
Is it possible in Vaadin?
I have an image and I want to get pixel color from image. Something like this:
image.getPixel(100,100).Color
Is it possible in Vaadin?
If you are sure that com.vaadin.ui.Image.getSource() method will return a FileResource you can use this code
FileResource resource = (FileResource) image.getSource();
File file = resource.getSourceFile();
BufferedImage img = ImageIO.read(file);
img.getRGB(0,0);
Method BufferedImage.getRGB() returns integer that represents rgba color. You can extract Red, Green, Blue and Alpha values using method provided in this Stack Overflow answer.
Assuming other scenario ( getSource() returned ExternalResource i.e. ) I would strongly suggest writing custom Vaadin component based on GWT Image which make conversion of the link/resource/file/image to BufferedImage before displaying content to user. Therefore you will be able to actually get BufferedImage from your custom component every time you need it.