forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPImage.html
More file actions
146 lines (126 loc) · 4.67 KB
/
Copy pathPImage.html
File metadata and controls
146 lines (126 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
layout: default
---
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
<tr class="name-row">
<th scope="row">Name</th>
<td><h3>PImage</h3></td>
</tr>
<tr class="">
<th scope="row">Examples</th>
<td><div class="example"><img src="/reference/PImage.jpg" alt="example pic" /><pre class="margin">PImage b;
b = loadImage("laDefense.jpg");
image(b, 0, 0);</pre></div></td>
</tr>
<tr class="">
<th scope="row">Description</th>
<td><p>Datatype for storing images. Processing can display <b>.gif</b>, <b>.jpg</b>, <b>.tga</b>, and <b>.png</b>. images.
Images may be displayed in 2D and 3D space. Before an image is used, it must be loaded with the <b>loadImage()</b> function.
The <b>PImage</b> object contains fields for the width and height of the image, as well as an array called <b>pixels[]</b> which contains the values for every pixel in the image.
A group of methods, described below, allow easy access to the image's pixels and alpha channel and simplify the process of compositing. </p>
<p>Before using the <b>pixels[]</b> array, be sure to use the <b>loadPixels()</b> method on the image to make sure that the pixel data is properly loaded. </p>
<p>To create a new image, use the <b>createImage()</b> function (do not use <b>new PImage()</b>).</p></td>
</tr>
<tr class="">
<th scope="row">Fields</th>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row"><a href="../reference/PImage_width">width</a></th>
<td>Shape document width</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_height">height</a></th>
<td>Shape document width</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_pixels">pixels[]</a></th>
<td>Shape document width</td>
</tr>
</table>
</td>
</tr>
<tr class="">
<th scope="row">Methods</th>
<td><table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row"><a href="../reference/PImage_get_">get()</a></th>
<td>Reads the color of any pixel or grabs a rectangle of pixels</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_set_">set()</a></th>
<td>Writes a color to any pixel or writes an image into another</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_copy_">copy()</a></th>
<td>Copies the entire image</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_mask_">mask()</a></th>
<td>Masks part of the image from displaying</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_blend_">blend()</a></th>
<td>Copies a pixel or rectangle of pixels using different blending modes</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_filter_">filter()</a></th>
<td>Converts the image to grayscale or black and white</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_save_">save()</a></th>
<td>Saves the image to a TIFF, TARGA, PNG, or JPEG file</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_resize_">resize()</a></th>
<td> Changes the size of an image to a new width and height</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_loadPixels_">loadPixels()</a></th>
<td> Loads the pixel data for the image into its pixels[] array</td>
</tr>
<tr class="">
<th scope="row"><a href="../reference/PImage_updatePixels_">updatePixels()</a></th>
<td>Updates the image with the data in its pixels[] array</td>
</tr>
</table></td>
</tr>
<tr class="">
<th scope="row"><!--*-->Constructor<!--*--></th>
<td><pre>PImage()</pre><br />
<pre>PImage(<kbd>width</kbd>,<kbd>height</kbd>)</pre><br />
<pre>PImage(<kbd>width</kbd>,<kbd>height</kbd>,<kbd>format</kbd>)</pre><br />
<pre>PImage(<kbd>img</kbd>)</pre><br /></td>
</tr>
<tr class="">
<th scope="row">Parameters</th>
<td><table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row">width</th>
<td>int: image width</td>
</tr>
<tr class="">
<th scope="row">height</th>
<td>int: image height</td>
</tr>
<tr class="">
<th scope="row">format</th>
<td>Either RGB, ARGB, ALPHA (grayscale alpha channel)</td>
</tr>
<tr class="">
<th scope="row">img</th>
<td>an image: assumes @pjs preload has been used to fully download the data and the img is valid</td>
</tr>
</table></td>
</tr>
<tr class="">
<th scope="row">Usage</th>
<td>Web & Application</td>
</tr>
<tr class="">
<th scope="row">Related</th>
<td><a href="../reference/loadImage_">loadImage()</a><br />
<a href="../reference/imageMode_">imageMode()</a><br />
<a href="../reference/createImage_">createImage()</a></td>
</tr>
</table>