processing.core
Class PGraphicsJava2D

java.lang.Object
  extended byprocessing.core.PImage
      extended byprocessing.core.PGraphics
          extended byprocessing.core.PGraphicsJava2D
All Implemented Interfaces:
java.lang.Cloneable, PConstants
Direct Known Subclasses:
PGraphicsPDF

public class PGraphicsJava2D
extends PGraphics

Subclass for PGraphics that implements the graphics API in Java 1.3+ using Java 2D.

Pixel operations too slow? As of release 0085 (the first beta), the default renderer uses Java2D. It's more accurate than the renderer used in alpha releases of Processing (it handles stroke caps and joins, and has better polygon tessellation), but it's super slow for handling pixels. At least until we get a chance to get the old 2D renderer (now called P2D) working in a similar fashion, you can use size(w, h, P3D) instead of size(w, h) which will be faster for general pixel flipping madness.

To get access to the Java 2D "Graphics2D" object for the default renderer, use:

Graphics2D g2 = ((PGraphicsJava2D)g).g2;
This will let you do Java 2D stuff directly, but is not supported in any way shape or form. Which just means "have fun, but don't complain if it breaks."


Field Summary
 boolean fillGradient
           
 java.awt.Paint fillGradientObject
           
 java.awt.Graphics2D g2
           
 boolean strokeGradient
           
 java.awt.Paint strokeGradientObject
           
 
Fields inherited from class processing.core.PGraphics
A, AB, AG, ambientB, ambientG, ambientR, AR, AUTO_NORMAL, B, backgroundColor, BEEN_LIT, bezierDetail, camera, cameraAspect, cameraFar, cameraFOV, cameraInv, cameraNear, cameraX, cameraY, cameraZ, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, currentLightFalloffConstant, currentLightFalloffLinear, currentLightFalloffQuadratic, currentLightSpecular, curveTightness, DA, DB, DG, DR, EB, EG, ellipseMode, emissiveB, emissiveG, emissiveR, ER, fill, fillColor, G, height1, image, INDEX, lightCount, lightDiffuse, lightFalloffConstant, lightFalloffLinear, lightFalloffQuadratic, lightNormal, lightPosition, lightSpecular, lightSpotAngle, lightSpotAngleCos, lightSpotConcentration, lightType, LINE_FIELD_COUNT, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33, MANUAL_SHAPE_NORMAL, MANUAL_VERTEX_NORMAL, MAX_LIGHTS, modelview, modelviewInv, MX, MY, MZ, normalCount, normalMode, normalX, normalY, normalZ, NX, NY, NZ, pixelCount, projection, R, raw, rectMode, SA, SB, SG, SHINE, shininess, SPA, SPB, specularA, specularB, specularG, specularR, SPG, sphereDetail, SPR, SR, stencil, stroke, STROKE_MODE, STROKE_WEIGHT, strokeCap, strokeColor, strokeJoin, strokeWeight, SW, textAlign, textAlignY, textFont, textFontNative, textFontNativeMetrics, textLeading, textMode, textSize, TEXTURE_INDEX, textureImage, textureMode, textureU, textureV, textX, textY, textZ, tint, tintColor, TRI_DIFFUSE_A, TRI_DIFFUSE_B, TRI_DIFFUSE_G, TRI_DIFFUSE_R, TRI_SPECULAR_A, TRI_SPECULAR_B, TRI_SPECULAR_G, TRI_SPECULAR_R, TRIANGLE_COLOR_COUNT, TRIANGLE_FIELD_COUNT, U, V, VERTEX1, VERTEX2, VERTEX3, VW, VX, VY, VZ, width1, X, Y, Z, zbuffer
 
Fields inherited from class processing.core.PImage
cache, format, height, imageMode, modified, mx1, mx2, my1, my2, parent, pixels, smooth, width
 
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BURN, CENTER, CENTER_RADIUS, CHATTER, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_AUTO_GZIP, DISABLE_DEPTH_TEST, DISABLE_ERROR_REPORT, DISABLE_TEXT_SMOOTH, DODGE, DOWN, DXF, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_NATIVE_FONTS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINES, LINUX, MACOS9, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NO_FLYING_POO, NORMALIZED, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PDF, PERSPECTIVE, PI, PIXEL_CENTER, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, WAIT, WHITESPACE, WINDOWS
 
Constructor Summary
PGraphicsJava2D(int iwidth, int iheight, PApplet parent)
          Constructor for the PGraphics object.
 
Method Summary
 void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12)
          Apply a 3x2 affine transformation matrix.
 void background(PImage image)
          Takes an RGB or ARGB image and sets it as the background.
 void beginDraw()
          Prepares the PGraphics for drawing.
 void beginRaw(PGraphics recorderRaw)
           
 void beginShape(int kind)
          Start a new shape.
 void bezierDetail(int detail)
          Ignored (not needed) in Java 2D.
 void bezierVertex(float x1, float y1, float x2, float y2, float x3, float y3)
           
 void blend(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          Blends one area of this image to another area.
 void blend(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          Copies area of one image into another PImage object.
 void breakShape()
          This feature is in testing, do not use or rely upon its implementation
 void clear()
           
 void copy(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
          Copy things from one area of this image to another area in the same image.
 void copy(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          Copies area of one image into another PImage object.
 void curveDetail(int detail)
          Ignored (not needed) in Java 2D.
 void curveVertex(float x, float y)
          See notes with the curve() function.
 void endDraw()
          This will finalize rendering so that it can be shown on-screen.
 void endRaw()
           
 void endShape(int mode)
           
 void filter(int kind)
          Method to apply a variety of basic filters to this image.
 void filter(int kind, float param)
          Method to apply a variety of basic filters to this image.
 PImage get()
          Grab a copy of the current pixel buffer.
 int get(int x, int y)
          Returns an ARGB "color" type (a packed 32 bit int with the color.
 PImage get(int x, int y, int w, int h)
          Grab a subsection of a PImage, and copy it into a fresh PImage.
 void line(float x1, float y1, float x2, float y2)
           
 void loadMatrix()
          Loads the current matrix into m00, m01 etc (or modelview and projection when using 3D) so that the values can be read.
 void loadPixels()
          Call this when you want to mess with the pixels[] array.
 void mask(int[] alpha)
          Use with caution on PGraphics.
 void mask(PImage alpha)
          Use with caution on PGraphics.
 void noSmooth()
          Disable smoothing.
 void point(float x, float y)
          End a path.
 void popMatrix()
           
 void pushMatrix()
           
 void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
           
 void resetMatrix()
          Load identity as the transform/model matrix.
 void resize(int iwidth, int iheight)
          Called in repsonse to a resize event, handles setting the new width and height internally, as well as re-allocating the pixel buffer for the new size.
 void rotate(float angle)
          Two dimensional rotation.
 void save(java.lang.String filename)
          Save this image to disk.
 void scale(float s)
           
 void scale(float sx, float sy)
           
 float screenX(float x, float y)
          Given an x and y coordinate, returns the x position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.
 float screenY(float x, float y)
          Given an x and y coordinate, returns the y position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.
 void set(int x, int y, int argb)
          Silently ignores if the coordinate is outside the image.
 void smooth()
          If true in PImage, use bilinear interpolation for copy() operations.
 void strokeCap(int cap)
           
 void strokeJoin(int join)
           
 void strokeWeight(float weight)
           
 float textAscent()
          Returns the ascent of the current font at the current size.
 float textDescent()
          Returns the descent of the current font at the current size.
 void textSize(float size)
          Same as parent, but override for native version of the font.
 void texture(PImage image)
          Set texture image for current shape.
 void textureMode(int mode)
          Set texture mode to either to use coordinates based on the IMAGE (more intuitive for new users) or NORMALIZED (better for advanced chaps)
 void translate(float tx, float ty)
           
 void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
           
 void updatePixels()
          Update the pixels[] buffer to the PGraphics image.
 void updatePixels(int x, int y, int c, int d)
          Update the pixels[] buffer to the PGraphics image.
 void vertex(float x, float y)
           
 void vertex(float x, float y, float z)
           
 void vertex(float x, float y, float u, float v)
           
 void vertex(float x, float y, float z, float u, float v)
           
 
Methods inherited from class processing.core.PGraphics
alpha, ambient, ambient, ambient, ambientLight, ambientLight, applyMatrix, arc, background, background, background, background, background, background, beginCamera, beginShape, bezier, bezier, bezierPoint, bezierTangent, bezierVertex, blue, box, box, brightness, camera, camera, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, curve, curve, curvePoint, curveTangent, curveTightness, curveVertex, defaults, directionalLight, displayable, dispose, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endShape, fill, fill, fill, fill, fill, fill, frustum, green, hint, hue, image, image, image, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, modelX, modelY, modelZ, noFill, noHint, normal, noStroke, noTint, ortho, ortho, perspective, perspective, point, pointLight, printCamera, printMatrix, printProjection, rect, rectMode, red, requestDisplay, rotate, rotateX, rotateY, rotateZ, saturation, scale, screenX, screenY, screenZ, setMainDrawingSurface, shininess, specular, specular, specular, specular, specular, sphere, sphereDetail, spotLight, stroke, stroke, stroke, stroke, stroke, stroke, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textFont, textFont, textLeading, textMode, textWidth, textWidth, tint, tint, tint, tint, tint, tint, translate
 
Methods inherited from class processing.core.PImage
blendColor, clone, imageMode, init, set
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g2

public java.awt.Graphics2D g2

fillGradient

public boolean fillGradient

fillGradientObject

public java.awt.Paint fillGradientObject

strokeGradient

public boolean strokeGradient

strokeGradientObject

public java.awt.Paint strokeGradientObject
Constructor Detail

PGraphicsJava2D

public PGraphicsJava2D(int iwidth,
                       int iheight,
                       PApplet parent)
Constructor for the PGraphics object. Use this to ensure that the defaults get set properly. In a subclass, use this(w, h) as the first line of a subclass' constructor to properly set the internal fields and defaults.

Parameters:
iwidth - viewport width
iheight - viewport height
Method Detail

resize

public void resize(int iwidth,
                   int iheight)
Called in repsonse to a resize event, handles setting the new width and height internally, as well as re-allocating the pixel buffer for the new size. Note that this will nuke any cameraMode() settings.

Overrides:
resize in class PGraphics

beginDraw

public void beginDraw()
Description copied from class: PGraphics
Prepares the PGraphics for drawing.

When creating your own PGraphics, you should call this before drawing anything.

Specified by:
beginDraw in class PGraphics

endDraw

public void endDraw()
Description copied from class: PGraphics
This will finalize rendering so that it can be shown on-screen.

When creating your own PGraphics, you should call this when you're finished drawing.

Specified by:
endDraw in class PGraphics

beginShape

public void beginShape(int kind)
Description copied from class: PGraphics
Start a new shape.

Differences between beginShape() and line() and point() methods.

beginShape() is intended to be more flexible at the expense of being a little more complicated to use. it handles more complicated shapes that can consist of many connected lines (so you get joins) or lines mixed with curves.

The line() and point() command are for the far more common cases (particularly for our audience) that simply need to draw a line or a point on the screen.

From the code side of things, line() may or may not call beginShape() to do the drawing. In the beta code, they do, but in the alpha code, they did not. they might be implemented one way or the other depending on tradeoffs of runtime efficiency vs. implementation efficiency &mdash meaning the speed that things run at vs. the speed it takes me to write the code and maintain it. for beta, the latter is most important so that's how things are implemented.

Specified by:
beginShape in class PGraphics

textureMode

public void textureMode(int mode)
Description copied from class: PGraphics
Set texture mode to either to use coordinates based on the IMAGE (more intuitive for new users) or NORMALIZED (better for advanced chaps)

Overrides:
textureMode in class PGraphics

texture

public void texture(PImage image)
Description copied from class: PGraphics
Set texture image for current shape. Needs to be called between @see beginShape and @see endShape

Overrides:
texture in class PGraphics
Parameters:
image - reference to a PImage object

vertex

public void vertex(float x,
                   float y)
Specified by:
vertex in class PGraphics

vertex

public void vertex(float x,
                   float y,
                   float u,
                   float v)
Specified by:
vertex in class PGraphics

vertex

public void vertex(float x,
                   float y,
                   float z)
Specified by:
vertex in class PGraphics

vertex

public void vertex(float x,
                   float y,
                   float z,
                   float u,
                   float v)
Specified by:
vertex in class PGraphics

bezierVertex

public void bezierVertex(float x1,
                         float y1,
                         float x2,
                         float y2,
                         float x3,
                         float y3)
Overrides:
bezierVertex in class PGraphics

curveVertex

public void curveVertex(float x,
                        float y)
Description copied from class: PGraphics
See notes with the curve() function.

Overrides:
curveVertex in class PGraphics

breakShape

public void breakShape()
Description copied from class: PGraphics
This feature is in testing, do not use or rely upon its implementation

Overrides:
breakShape in class PGraphics

endShape

public void endShape(int mode)
Specified by:
endShape in class PGraphics

point

public void point(float x,
                  float y)
Description copied from class: PGraphics
End a path. Use this with beginPath() to close out a compound path.

This will probably be available only with the OpenGL renderer, because it has a built-in tesselator from GLU.

Overrides:
point in class PGraphics

line

public void line(float x1,
                 float y1,
                 float x2,
                 float y2)
Overrides:
line in class PGraphics

triangle

public void triangle(float x1,
                     float y1,
                     float x2,
                     float y2,
                     float x3,
                     float y3)
Overrides:
triangle in class PGraphics

quad

public void quad(float x1,
                 float y1,
                 float x2,
                 float y2,
                 float x3,
                 float y3,
                 float x4,
                 float y4)
Overrides:
quad in class PGraphics

bezierDetail

public void bezierDetail(int detail)
Ignored (not needed) in Java 2D.

Overrides:
bezierDetail in class PGraphics

curveDetail

public void curveDetail(int detail)
Ignored (not needed) in Java 2D.

Overrides:
curveDetail in class PGraphics

textAscent

public float textAscent()
Description copied from class: PGraphics
Returns the ascent of the current font at the current size. This is a method, rather than a variable inside the PGraphics object because it requires calculation.

Overrides:
textAscent in class PGraphics

textDescent

public float textDescent()
Description copied from class: PGraphics
Returns the descent of the current font at the current size. This is a method, rather than a variable inside the PGraphics object because it requires calculation.

Overrides:
textDescent in class PGraphics

textSize

public void textSize(float size)
Same as parent, but override for native version of the font.

Also gets called by textFont, so the metrics will get recorded properly.

Overrides:
textSize in class PGraphics

translate

public void translate(float tx,
                      float ty)
Overrides:
translate in class PGraphics

rotate

public void rotate(float angle)
Description copied from class: PGraphics
Two dimensional rotation.

Additional background.

Same as rotateZ (this is identical to a 3D rotation along the z-axis) but included for clarity. It'd be weird for people drawing 2D graphics to be using rotateZ. And they might kick our a-- for the confusion.

Overrides:
rotate in class PGraphics

scale

public void scale(float s)
Overrides:
scale in class PGraphics

scale

public void scale(float sx,
                  float sy)
Overrides:
scale in class PGraphics

pushMatrix

public void pushMatrix()
Overrides:
pushMatrix in class PGraphics

popMatrix

public void popMatrix()
Overrides:
popMatrix in class PGraphics

resetMatrix

public void resetMatrix()
Description copied from class: PGraphics
Load identity as the transform/model matrix. Same as glLoadIdentity().

Overrides:
resetMatrix in class PGraphics

applyMatrix

public void applyMatrix(float n00,
                        float n01,
                        float n02,
                        float n10,
                        float n11,
                        float n12)
Description copied from class: PGraphics
Apply a 3x2 affine transformation matrix.

Overrides:
applyMatrix in class PGraphics

loadMatrix

public void loadMatrix()
Description copied from class: PGraphics
Loads the current matrix into m00, m01 etc (or modelview and projection when using 3D) so that the values can be read.

Note that there is no "updateMatrix" because that gets too complicated (unnecessary) when considering the 3D matrices.

Overrides:
loadMatrix in class PGraphics

screenX

public float screenX(float x,
                     float y)
Description copied from class: PGraphics
Given an x and y coordinate, returns the x position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.

Overrides:
screenX in class PGraphics

screenY

public float screenY(float x,
                     float y)
Description copied from class: PGraphics
Given an x and y coordinate, returns the y position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.

Overrides:
screenY in class PGraphics

strokeWeight

public void strokeWeight(float weight)
Overrides:
strokeWeight in class PGraphics

strokeJoin

public void strokeJoin(int join)
Overrides:
strokeJoin in class PGraphics

strokeCap

public void strokeCap(int cap)
Overrides:
strokeCap in class PGraphics

background

public void background(PImage image)
Description copied from class: PGraphics
Takes an RGB or ARGB image and sets it as the background.

Note that even if the image is set as RGB, the high 8 bits of each pixel should be set opaque (0xFF000000), because the image data will be copied directly to the screen, and non-opaque background images may have strange behavior. Using image.filter(OPAQUE) will handle this easily.

When using 3D, this will also clear out the zbuffer and stencil buffer if they exist.

Overrides:
background in class PGraphics

clear

public void clear()

smooth

public void smooth()
Description copied from class: PImage
If true in PImage, use bilinear interpolation for copy() operations. When inherited by PGraphics, also controls shapes.

Overrides:
smooth in class PImage

noSmooth

public void noSmooth()
Description copied from class: PImage
Disable smoothing. See smooth().

Overrides:
noSmooth in class PImage

beginRaw

public void beginRaw(PGraphics recorderRaw)
Overrides:
beginRaw in class PGraphics

endRaw

public void endRaw()
Overrides:
endRaw in class PGraphics

loadPixels

public void loadPixels()
Description copied from class: PImage
Call this when you want to mess with the pixels[] array.

For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array

Overrides:
loadPixels in class PImage

updatePixels

public void updatePixels()
Update the pixels[] buffer to the PGraphics image.

Unlike in PImage, where updatePixels() only requests that the update happens, in PGraphicsJava2D, this will happen immediately.

Overrides:
updatePixels in class PImage

updatePixels

public void updatePixels(int x,
                         int y,
                         int c,
                         int d)
Update the pixels[] buffer to the PGraphics image.

Unlike in PImage, where updatePixels() only requests that the update happens, in PGraphicsJava2D, this will happen immediately.

Overrides:
updatePixels in class PImage

get

public int get(int x,
               int y)
Description copied from class: PImage
Returns an ARGB "color" type (a packed 32 bit int with the color. If the coordinate is outside the image, zero is returned (black, but completely transparent).

If the image is in RGB format (i.e. on a PVideo object), the value will get its high bits set, just to avoid cases where they haven't been set already.

If the image is in ALPHA format, this returns a white with its alpha value set.

This function is included primarily for beginners. It is quite slow because it has to check to see if the x, y that was provided is inside the bounds, and then has to check to see what image type it is. If you want things to be more efficient, access the pixels[] array directly.

Overrides:
get in class PImage

get

public PImage get(int x,
                  int y,
                  int w,
                  int h)
Description copied from class: PImage
Grab a subsection of a PImage, and copy it into a fresh PImage. This honors imageMode() for the coordinates.

Overrides:
get in class PImage

get

public PImage get()
Grab a copy of the current pixel buffer.

Overrides:
get in class PImage

set

public void set(int x,
                int y,
                int argb)
Description copied from class: PImage
Silently ignores if the coordinate is outside the image.

Overrides:
set in class PImage

mask

public void mask(int[] alpha)
Description copied from class: PGraphics
Use with caution on PGraphics. This should not be used with the base PGraphics that's tied to a PApplet, but it can be used with user-created PGraphics objects that are drawn to the screen.

Overrides:
mask in class PGraphics

mask

public void mask(PImage alpha)
Description copied from class: PGraphics
Use with caution on PGraphics. This should not be used with the base PGraphics that's tied to a PApplet, but it can be used with user-created PGraphics objects that are drawn to the screen.

Overrides:
mask in class PGraphics

filter

public void filter(int kind)
Description copied from class: PImage
Method to apply a variety of basic filters to this image.

Luminance conversion code contributed by toxi

Gaussian blur code contributed by Mario Klingemann

Overrides:
filter in class PImage

filter

public void filter(int kind,
                   float param)
Description copied from class: PImage
Method to apply a variety of basic filters to this image. These filters all take a parameter.

Gaussian blur code contributed by Mario Klingemann and later updated by toxi for better speed.

Overrides:
filter in class PImage

copy

public void copy(int sx,
                 int sy,
                 int sw,
                 int sh,
                 int dx,
                 int dy,
                 int dw,
                 int dh)
Description copied from class: PImage
Copy things from one area of this image to another area in the same image.

Overrides:
copy in class PImage

copy

public void copy(PImage src,
                 int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
Description copied from class: PImage
Copies area of one image into another PImage object.

Overrides:
copy in class PImage

blend

public void blend(int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
Description copied from class: PImage
Blends one area of this image to another area.

Overrides:
blend in class PImage
See Also:
PImage.blendColor(int,int,int)

blend

public void blend(PImage src,
                  int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
Description copied from class: PImage
Copies area of one image into another PImage object.

Overrides:
blend in class PImage
See Also:
PImage.blendColor(int,int,int)

save

public void save(java.lang.String filename)
Description copied from class: PImage
Save this image to disk.

As of revision 0100, this function requires an absolute path, in order to avoid confusion. To save inside the sketch folder, use the function savePath() from PApplet, or use saveFrame() instead.

As of revision 0115, when using Java 1.4 and later, you can write to several formats besides tga and tiff. If Java 1.4 is installed and the extension used is supported (usually png, jpg, jpeg, bmp, and tiff), then those methods will be used to write the image. To get a list of the supported formats for writing, use:
println(javax.imageio.ImageIO.getReaderFormatNames())

To use the original built-in image writers, use .tga as the extension, or don't include an extension, in which case .tif will be added.

The ImageIO API claims to support wbmp files, however they probably require a black and white image. Basic testing produced a zero-length file with no error.

As of revision 0116, savePath() is not needed if this object has been created (as recommended) via createImage() or createGraphics() or one of its neighbors.

Overrides:
save in class PImage