MCPcopy Index your code
hub / github.com/benfry/processing4 / loadImageIO

Method loadImageIO

core/src/processing/awt/ShimAWT.java:479–512  ·  view source on GitHub ↗

Use Java 1.4 ImageIO methods to load an image.

(PApplet sketch, String filename)

Source from the content-addressed store, hash-verified

477 * Use Java 1.4 ImageIO methods to load an image.
478 */
479 static protected PImage loadImageIO(PApplet sketch, String filename) {
480 InputStream stream = sketch.createInput(filename);
481 if (stream == null) {
482 System.err.println("The image " + filename + " could not be found.");
483 return null;
484 }
485
486 try {
487 BufferedImage bi = ImageIO.read(stream);
488 //PImage outgoing = new PImage(bi.getWidth(), bi.getHeight());
489 PImage outgoing = new PImageAWT(bi);
490 outgoing.parent = sketch;
491
492 //bi.getRGB(0, 0, outgoing.width, outgoing.height,
493 // outgoing.pixels, 0, outgoing.width);
494
495 // check the alpha for this image
496 // was gonna call getType() on the image to see if RGB or ARGB,
497 // but it's not actually useful, since gif images will come through
498 // as TYPE_BYTE_INDEXED, which means it'll still have to check for
499 // the transparency. also, would have to iterate through all the other
500 // types and guess whether alpha was in there, so.. just gonna stick
501 // with the old method.
502 outgoing.checkAlpha();
503
504 stream.close();
505 // return the image
506 return outgoing;
507
508 } catch (Exception e) {
509 e.printStackTrace();
510 return null;
511 }
512 }
513
514
515 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 1

loadImageMethod · 0.95

Calls 6

createInputMethod · 0.45
printlnMethod · 0.45
readMethod · 0.45
checkAlphaMethod · 0.45
closeMethod · 0.45
printStackTraceMethod · 0.45

Tested by

no test coverage detected