Name

createImage()

Examples
img = createImage(66, 66, RGB)
img.loadPixels()
for i in range(len(img.pixels)): 
    img.pixels[i] = color(0, 90, 102)
img.updatePixels()
image(img, 17, 17)
img = createImage(66, 66, ARGB)
img.loadPixels()
for i in range(len(img.pixels)): 
    img.pixels[i] = color(0, 90, 102, i % img.width * 2)
img.updatePixels()
image(img, 17, 17)
image(img, 34, 34)
Description Creates a new PImage (the datatype for storing images). This provides a fresh buffer of pixels to play with. Set the size of the buffer with the width and height parameters. The format parameter defines how the pixels are stored. See the PImage reference for more information.

Be sure to include all three parameters, specifying only the width and height (but no format) will produce a strange error.

Advanced users please note that createImage() should be used instead of the syntax new PImage().
Syntax
createImage(w, h, format)
Parameters
wint: width in pixels
hint: height in pixels
formatint: Either RGB, ARGB, ALPHA (grayscale alpha channel)
Related PImage
PGraphics

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.