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

Method get

core/src/processing/core/PImage.java:581–590  ·  view source on GitHub ↗

Reads the color of any pixel or grabs a section of an image. If no parameters are specified, the entire image is returned. Use the x and y parameters to get the value of one pixel. Get a section of the display window by specifying an additional width and height parameter.

(int x, int y)

Source from the content-addressed store, hash-verified

579 * @see PApplet#copy(PImage, int, int, int, int, int, int, int, int)
580 */
581 public int get(int x, int y) {
582 if ((x < 0) || (y < 0) || (x >= pixelWidth) || (y >= pixelHeight)) return 0;
583
584 return switch (format) {
585 case RGB -> pixels[y * pixelWidth + x] | 0xff000000;
586 case ARGB -> pixels[y * pixelWidth + x];
587 case ALPHA -> (pixels[y * pixelWidth + x] << 24) | 0xffffff;
588 default -> 0;
589 };
590 }
591
592
593 /**

Callers 4

testLoadMethod · 0.95
cloneMethod · 0.95
copyMethod · 0.95
blendMethod · 0.95

Calls 1

getImplMethod · 0.95

Tested by 1

testLoadMethod · 0.76