Reputation: 464
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?
Upvotes: 3
Views: 2796
Reputation: 1719
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.
Upvotes: 1