MCPcopy Index your code
hub / github.com/processing/processing / loadImageIO

Method loadImageIO

core/src/processing/core/PApplet.java:5715–5747  ·  view source on GitHub ↗

Use Java 1.4 ImageIO methods to load an image.

(String filename)

Source from the content-addressed store, hash-verified

5713 * Use Java 1.4 ImageIO methods to load an image.
5714 */
5715 protected PImage loadImageIO(String filename) {
5716 InputStream stream = createInput(filename);
5717 if (stream == null) {
5718 System.err.println("The image " + filename + " could not be found.");
5719 return null;
5720 }
5721
5722 try {
5723 BufferedImage bi = ImageIO.read(stream);
5724 PImage outgoing = new PImage(bi.getWidth(), bi.getHeight());
5725 outgoing.parent = this;
5726
5727 bi.getRGB(0, 0, outgoing.width, outgoing.height,
5728 outgoing.pixels, 0, outgoing.width);
5729
5730 // check the alpha for this image
5731 // was gonna call getType() on the image to see if RGB or ARGB,
5732 // but it's not actually useful, since gif images will come through
5733 // as TYPE_BYTE_INDEXED, which means it'll still have to check for
5734 // the transparency. also, would have to iterate through all the other
5735 // types and guess whether alpha was in there, so.. just gonna stick
5736 // with the old method.
5737 outgoing.checkAlpha();
5738
5739 stream.close();
5740 // return the image
5741 return outgoing;
5742
5743 } catch (Exception e) {
5744 printStackTrace(e);
5745 return null;
5746 }
5747 }
5748
5749
5750 /**

Callers 1

loadImageMethod · 0.95

Calls 8

createInputMethod · 0.95
checkAlphaMethod · 0.95
printStackTraceMethod · 0.95
printlnMethod · 0.45
readMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected