Hi,
I got it working, that on the smartphone, I can click on the Upload button
and the camera pops up, then taking a photo, use it and then save it to a blob column in the DB.
The image is then directly shown in the screen.
So far, so good…
But, I would like to scale the image, before I save it into the DB.
I could figure it out, how to read the image from the blob column (image column in the scree)
and scale it using imgsclr…
But then, how to write it back into the column in the form to save it?
Because it is an image column, I to not have the method setValue().
Only setValueSource is available.
I tried multiple scenarios, but could not find out how to i.e. convert or use
the BufferedImage which I get from Scalr as or to a ValueSource.
Any idea?
Here is an example of what I tried and which does not work:
cameraImage is the form image column in my screen…
public void resizeImage() {
ByteArrayInputStream bais = new ByteArrayInputStream(cameraImage.getValueSource().getValue());
try {
BufferedImage newImage = Scalr.resize(ImageIO.read(bais), 200);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(newImage, “png”, baos);
byte[] bytes = baos.toByteArray();
//cameraImage.setSrc(String.valueOf(baos));
} catch (IOException e) {
throw new RuntimeException(e);
}
}