Files
2015-09-01 19:05:48 -04:00

251 lines
9.8 KiB
Groff

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PImage | reference | Processing.js</title>
<link rel="stylesheet" href="../css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="../css/syntax.css" type="text/css" />
<link rel="stylesheet" href="../css/processing-js.css" type="text/css" />
<script src="../js/processing.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="../js/jquery.tweet.min.js" type="text/javascript"></script>
<script src="../js/tabselector.js" type="text/javascript"></script>
<script src="http://cdn.webglstats.com/stat.js" defer="defer" async="async"></script>
<script type="text/javascript">
// Only do tracking on the actual site
if (document.location.host === "processingjs.org") {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8565070-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
}());
}
</script>
</head>
<body>
<div class="container">
<div class="header">
<a href="http://processingjs.org/"><img src="../images/header.png" width="177" height="42"></a>
</div>
<span class="tagline">a port of the Processing Visualization Language</span>
<div class="navbar">
<canvas width="940px" height="78px" data-processing-sources="/sketches/bannerSketch.pde"></canvas>
<ul>
<li><a href="http://processingjs.org/"><span>home</span></a></li>
<li><a href="http://processingjs.org/download/"><span>download</span></a></li>
<li><a href="index.html"><span>reference</span></a></li>
<li><a href="http://processingjs.org/exhibition/"><span>exhibition</span></a></li>
<li><a href="http://processingjs.org/learning/"><span>learning</span></a></li>
<li><a href="http://processingjs.org/articles/"><span>articles</span></a></li>
<li><a href="http://processingjs.org/community/"><span>community</span></a></li>
<li><a href="http://processingjs.org/blog/"><span>blog</span></a></li>
</ul>
<a class="viewsource" href="http://processingjs.org/sketches/bannerSketch.pde">view source</a>
</div>
<div class="page row">
<div class="span11">
<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="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="PImage_width">width</a></th>
<td>Shape document width</td>
</tr>
<tr class="">
<th scope="row"><a href="PImage_height">height</a></th>
<td>Shape document width</td>
</tr>
<tr class="">
<th scope="row"><a href="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="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="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="PImage_copy_">copy()</a></th>
<td>Copies the entire image</td>
</tr>
<tr class="">
<th scope="row"><a href="PImage_mask_">mask()</a></th>
<td>Masks part of the image from displaying</td>
</tr>
<tr class="">
<th scope="row"><a href="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="PImage_filter_">filter()</a></th>
<td>Converts the image to grayscale or black and white</td>
</tr>
<tr class="">
<th scope="row"><a href="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="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="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="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="loadImage_.1">loadImage()</a><br />
<a href="imageMode_.1">imageMode()</a><br />
<a href="createImage_.1">createImage()</a></td>
</tr>
</table>
<div class="cclicense">
<p>This reference is licensed under the CC BY-NC-SA 2.0 license:</p>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.0/">
<img alt="Creative Commons License" border="0" src="../images/somerights20.gif" />
</a>
</div>
</div>
<div class="sidebar span4">
<h3><a href="http://processingjs.org/download/">Downloads</a></h3>
<ul>
<li><a href="http://processingjs.org/download/">Download the latest version of Processing.js!</a></li>
</ul>
<h3><a href="http://processingjs.org/articles/">Articles</a></h3>
<ul>
<li><a href="http://processingjs.org/articles/jsQuickStart.html">Quick Start - JavaScript Developer</a></li>
<li><a href="http://processingjs.org/articles/p5QuickStart.html">Quick Start - Processing Developer</a></li>
<li><a href="http://processingjs.org/articles/RenderingModes.html">Rendering Modes</a></li>
<li><a href="http://processingjs.org/articles/PomaxGuide.html">Pomax's Guide to processing-js</a></li>
</ul>
<h3><a>Web IDEs</a></h3>
<ul>
<li><a href="http://sketchpad.cc">Sketchpad.cc</a></li>
<li><a href="http://processingjs.org/tools/processing-helper.html">Processing.js Helper</a></li>
<li><a href="http://www.openprocessing.org">OpenProcessing.org</a></li>
</ul>
<h3><a href="http://processingjs.org/community/">Community</a></h3>
<ul>
<li><a href="irc://irc.mozilla.org/processing.js">IRC Channel</a></li>
<li><a href="http://processing-js.lighthouseapp.com/">Bug Tracker</a></li>
<li><a href="http://github.com/processing-js/processing-js/">Github Repository</a></li>
<li><a href="http://groups.google.com/group/processingjs">Google Group</a></li>
<li><a href="http://zenit.senecac.on.ca/wiki/index.php/">Open Source @ Seneca</a></li>
</ul>
<h3><a href="http://twitter.com/processingjs">Twitter Feed</a></h3>
<div class="twitter"></div>
</div>
</div>
<div class="footer">
Processing is an open visualization language developed by
<a href="http://benfry.com/">Ben Fry</a> &amp; <a href="http://reas.com/">Casey Reas</a>,
and originally ported to Javascript by
<a href="http://ejohn.org/blog/processingjs/">John Resig</a>.
Processing.js is maintained by the Processing.js team.
</div>
</div>
<a href="http://github.com/processing-js/processing-js/">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="../images/forkme-right-orange.png" alt="Fork me on GitHub">
</a>
</body>
</html>