Load images - new thread
in
Programming Questions
•
2 years ago
I am trying to load flickr images in a new thread using this:
I deleted the caching, because I don't need it, someone also posted the code without caching here: (
p5wiki_async_loader )
Problem is that I get this error:
java.lang.ClassCastException: [I cannot be cast to [B
Code is in databuffer class, around line 40: return new PImage(bimg);
What might be the problem?
Images are loaded and I can save them using saveBytes("test.jpg",bytes);
- public PImage getAsImage() {
- try {
-
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- BufferedImage bimg = ImageIO.read(bis);
- return new PImage(bimg);
- } catch (Exception e) {
- println(e);
- System.err.println("Can't create image from buffer");
- }
- return null;
- }
1