Education/Projects/ProcessingForTheWeb/PImage.get: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with '== Summary == This is a method of the PImage class written for Education/Projects/ProcessingForTheWeb. Gets the color of a pixel, a group of pixels, or the entire image. [h…')
 
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Summary ==
== Summary ==


This is a method of the PImage class written for [[Education/Projects/ProcessingForTheWeb]]. Gets the color of a pixel, a group of pixels, or the entire image.  
This is a method of the PImage class written for [[Education/Projects/ProcessingForTheWeb]]. Gets the color of a pixel, a group of pixels, or the entire image. [http://processing.org/reference/PImage_get_.html View official Reference]  
[http://processing.org/reference/PImage_get_.html View official Reference]


=== Examples ===
=== Examples ===


PImage img = loadImage("tower.jpg");<br />
<br>  
background(img);<br />
PImage b = img.get(50, 0, 50, 100); <br />


image(b, 0, 0); <br />
void setup()
{     
      size(250,200);
      background(0);
}


=== Syntax ===
PImage pimg = new PImage(loadImage("fish.jpg"));
PImage pimg2 = pimg.get(0,0,64,46);
color c= pimg.get(120,0);
fill(c);


img.get():                    returns the entire image<br />
void draw()
img.get(x, y):                returns the color of a single pixel in the img pixels[y*width+x]<br />
{
img.get(x, y, width, height): returns a section of the display window by specifing an additional width and height parameter. If the pixel requested is outside of the image window, black is returned. <br />
      image(pimg,0,0);
      rect(25, 25, 50, 50);
      image(pimg2,0,93);
}
 
<br><br> [[Image:PImageGet.jpg]]
 
=== Syntax  ===
 
{| class="wikitable" border="1" width="700"
|-
!
! Description
|-
| img.get()  
| returns the entire image
|-
| img.get(x, y)  
| returns the color of a single pixel in the img pixels[y*width+x]
|-
| img.get(x, y, width, height)  
| returns a section of the display window by specifing an additional width and height parameter. If the pixel requested is outside of the image window, black is returned.
|}


== Parameters ==
== Parameters ==


img: PImage  
{| class="wikitable" border="1" width="700"
x:      x-coordinate of the pixel<br />
|-
y:      y-coordinate of the pixel<br />
!
widthwidth of pixel rectangle to get<br />
! Description
heightheight of pixel rectangle to get<br />
|-
|img
|PImage
|-
|x
|x-coordinate of the pixel
|-
|y
|y-coordinate of the pixel
|-
|width
|width of pixel rectangle to get
|-
|height
|height of pixel rectangle to get
|}


== Returns ==
== Returns ==
Line 43: Line 84:


=== Tests ===
=== Tests ===
{| width="200" border="1" cellpadding="1" cellspacing="1"
|-
| Test
| Location
|-
| All get() functionality
| [http://matrix.senecac.on.ca/~asobiepa/Processing/PImage/PImageGet.html get()]
|}

Latest revision as of 01:38, 28 November 2009

Summary

This is a method of the PImage class written for Education/Projects/ProcessingForTheWeb. Gets the color of a pixel, a group of pixels, or the entire image. View official Reference

Examples


void setup() 
{      
      size(250,200);
      background(0);
}
PImage pimg = new PImage(loadImage("fish.jpg"));
PImage pimg2 = pimg.get(0,0,64,46);
color c= pimg.get(120,0);
fill(c);
void draw() 
{ 
      image(pimg,0,0);
      rect(25, 25, 50, 50);
      image(pimg2,0,93);
}



PImageGet.jpg

Syntax

Description
img.get() returns the entire image
img.get(x, y) returns the color of a single pixel in the img pixels[y*width+x]
img.get(x, y, width, height) returns a section of the display window by specifing an additional width and height parameter. If the pixel requested is outside of the image window, black is returned.

Parameters

Description
img PImage
x x-coordinate of the pixel
y y-coordinate of the pixel
width width of pixel rectangle to get
height height of pixel rectangle to get

Returns

color or PImage

Bugs

Refer to the reference of each function for a specific bug report.

Bug Description Fixed?(Date)

Tests

Test Location
All get() functionality get()