Use of getContents with Images

0
Hello All, Can anyone explain to me ( preferably with a code example ) how I can load the contents of an Image object into a BufferedImage in Java in a Java Action. I tried the following which did not work. Is the use of getContents() correct here ? .....  ByteArrayOutputStream output = new ByteArrayOutputStream(); if( ElementPicture.getHasContents() == false ) {     ElementPicture.getContents(getContext(), output);     byte[] data = output.toByteArray();     ByteArrayInputStream input = new ByteArrayInputStream(data);     BufferedImage image = ImageIO.read(input); } ...... An access to image e.g. image.getWidth throws an exception Thanks for an answer Translated with www.DeepL.com/Translator (free version)
asked
1 answers
1

You can do somehting like this:

InputStream inputStream = Core.getImage(getContext(), this.ImageParameter.getMendixObject(), false);
BufferedImage bimg = ImageIO.read(inputStream);

 

answered