首页 > 文档 > PImage图像数据类型
2017
08-08

PImage图像数据类型

Name

PImage图像数据类型

Examples

PImage图像数据类型 - 第1张  | Processing编程艺术PImage图像数据类型 - 第2张  | Processing编程艺术PImage图像数据类型 - 第3张  | Processing编程艺术

PImage photo;

 

void setup() {

size(100, 100);

photo = loadImage(“laDefense.jpg”);

}

 

void draw() {

image(photo, 0, 0);

}

Description

Datatype for storing images. Processing can display .gif.jpg.tga, and .png images. Images may be displayed in 2D and 3D space. Before an image is used, it must be loaded with the loadImage()function. The PImage class contains fields for the width and height of the image, as well as an array called pixels[] that contains the values for every pixel in the image. The methods described below allow easy access to the image’s pixels and alpha channel and simplify the process of compositing.

Before using the pixels[] array, be sure to use the loadPixels() method on the image to make sure that the pixel data is properly loaded.

To create a new image, use the createImage() function. Do not use the syntax new PImage().

用于存储图像的数据类型。处理可以显示. gif. jpg. tga . png 图像。图像可以显示在2D 3D 空间中。在使用图像之前, 必须使用 loadImage () 函数来加载它。PImage 类包含图像的宽度和高度的字段, 以及一个名为像素 [] 的数组, 其中包含图像中每个像素的值。下面描述的方法可以方便地访问图像的像素和 alpha 通道, 并简化合成过程。

 

在使用像素 [] 数组之前, 请确保对图像使用 loadPixels () 方法, 以确保正确加载像素数据。

 

要创建新图像, 请使用 createImage () 函数。不要使用语法新的 PImage ()

Fields

pixels[]

Array containing the color of every pixel in the image

像素数组包含图像中每个像素的颜色

width

Image width

图像的宽度

height

Image height

图像的高度

Methods

loadPixels()

Loads the pixel data for the image into its pixels[] array

将图像的像素数据加载到其像素 [] 数组中

updatePixels()

Updates the image with the data in its pixels[] array

用其像素 [] 数组中的数据更新图像

resize()

Changes the size of an image to a new width and height

将图像的大小更改为新的宽度和高度

get()

Reads the color of any pixel or grabs a rectangle of pixels

读取任何像素的颜色或抓取像素矩形

set()

writes a color to any pixel or writes an image into another

将颜色写入任何像素或将图像写入另一个

mask()

Masks part of an image with another image as an alpha channel

将图像的一部分与另一个图像作为 alpha 通道进行屏蔽

filter()

Converts the image to grayscale or black and white

将图像转换为灰度或黑白

copy()

Copies the entire image

复制整个图像

blend()

Copies a pixel or rectangle of pixels using different blending modes

使用不同的混合模式复制像素或矩形

save()

Saves the image to a TIFF, TARGA, PNG, or JPEG file

保存图像

Constructor

PImage(width, height, format, factor)

Related

loadImage()
imageMode()
createImage()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。