So I'm trying to get a PNG image from stream.
image = ImageIO.read(inputStream);
And this code is running for ten seconds! I thought the problem was in slow InputStream, so I tried to load it in buffer first.
byte[] bytes = inputStreamToBytes(inputStream);
image = ImageIO.read(new ByteArrayInputStream(bytes));
And guess what! It takes about 100ms to load it from InputStream to buffer, but hell of a lot of time just to read it from byte array! A ten (TEN) seconds to read! From a RAM!
I'm doing it on Raspberry PI. And yes, I understand it's a toy, not a real computer. So I tried to do it on my MacBook Air. Really, two seconds are better then ten. But still a lot for some 800x600 PNG. So why it so? And what to do?
You probably need to install Java Native IO libraries they are not installed by default.
http://www.oracle.com/technetwork/java/install-jai-imageio-1-0-01-139659.html
If you don't have this lib installed all operations on images are performed in java not natively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With