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?