createImage()

本参考资料用于Processing 3.0+。 如果你使用的是前一版本,请在使用软件帮助菜单内的参考资料。. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

名称

createImage()

示例
 PImage img = createImage(66, 66, RGB);

img.loadPixels();


for (int i = 0;

i < img.pixels.length;

i++)
{  
img.pixels[i] = color(0, 90, 102);

  } img.updatePixels();

image(img, 17, 17);

 PImage img = createImage(66, 66, ARGB);

img.loadPixels();


for (int i = 0;

i < img.pixels.length;

i++)
{  
img.pixels[i] = color(0, 90, 102, i % img.width * 2);

  } img.updatePixels();

image(img, 17, 17);

image(img, 34, 34);

描述 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().

语法
createImage(w, h, format)
参数
w int: width in pixels
h int: height in pixels
format int: Either RGB, ARGB, ALPHA (grayscale alpha channel)
返回值 PImage
相关 PImage
PGraphics

Updated on October 2, 2018 05:02:05pm EDT

createImage()