元编程参考文档

像素图像

61 个节点

本页内容 61

像素图像

函数

重载 1/4

签名
像素图像() -> Pixel Image
PixelImage PixelImage()

此节点没有文档说明。

返回

像素图像Pixel Image

备注

We must have this empty constructor because PixelImage is deserializable as instance.

重载 2/4

签名
像素图像(宽度: 整数, 高度: 整数) -> Pixel Image
PixelImage PixelImage(int width, int height)

Creates a blank image of the given size, with every pixel transparent black (all channels 0).

参数

名称类型默认值说明
宽度整数—Number of columns, in pixels.
高度整数—Number of rows, in pixels.

返回

像素图像Pixel Image

重载 3/4

签名
像素图像 -> Pixel Image
    宽度: 整数
    高度: 整数
    平面值: 颜色数组
PixelImage PixelImage(
    int width,
    int height,
    ColorElement[] flat)

Creates an image from a single flat run of pixels, read row by row from the top-left corner.

参数

名称类型默认值说明
宽度整数—Number of columns, in pixels.
高度整数—Number of rows, in pixels.
平面值颜色数组—The pixels in row-major order: the first Width entries are the top row.

返回

像素图像Pixel Image

备注

The pixels are copied, so later changes to Flat do not affect the image. Any pixels beyond Width times Height are ignored.

重载 4/4

签名
像素图像(像素: 颜色数组数组) -> Pixel Image
PixelImage PixelImage(ColorElement[][] pixels)

此节点没有文档说明。

参数

名称类型默认值说明
像素颜色数组数组—Direct reference without copy.

返回

像素图像Pixel Image

备注

A zero-row array is a legitimate empty image and yields a 0x0 one. Reading
pixels[0].Length unconditionally used to throw here, which made
PixelImage.Clone throw on any empty image — so callers that could legitimately hold one
had to route around cloning rather than the constructor simply answering zero.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

复制图像

函数

Makes an independent copy of the image, so editing the copy leaves the original untouched.

签名
复制图像(Pixel Image: Pixel Image) -> Pixel Image
PixelImage Clone(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果Pixel Image

备注

Each row is copied up to PixelImage.Columns pixels. An empty image clones to an empty image.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

列数

函数

Width of the image in pixels, that is, the number of pixels in each row.

签名
列数(Pixel Image: Pixel Image) -> 整数
int Columns(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果整数

备注

Setting this does not resize PixelImage.Pixels; it only changes how much of each row the image reports and reads, so it should match the pixel data.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

像素

函数

重载 1/2

签名
像素(Pixel Image: Pixel Image, 索引: 整数) -> 颜色
ColorElement Item(PixelImage Pixel Image, int index)

Reads or writes a pixel by its position in row-major order, counting from 0 at the top-left corner along each row in turn, so index y * Columns + x is the pixel at column x of row y.

参数

名称类型默认值说明
Pixel ImagePixel Image—
索引整数—The pixel's position, from 0 to PixelImage.Columns × PixelImage.Rows - 1.

返回

结果颜色

重载 2/2

签名
像素(Pixel Image: Pixel Image, X: 整数, Y: 整数) -> 颜色
ColorElement Item(PixelImage Pixel Image, int x, int y)

Reads or writes the pixel at a column and row, the same as PixelImage.GetPixel and PixelImage.SetPixel.

参数

名称类型默认值说明
Pixel ImagePixel Image—
X整数—Column, counted from 0 at the left edge.
Y整数—Row, counted from 0 at the top edge.

返回

结果颜色
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

像素

函数

此节点没有文档说明。

签名
像素(Pixel Image: Pixel Image) -> 颜色数组数组
ColorElement[][] Pixels(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果颜色数组数组

备注

Row-major, aka. Pixels[Row][Col] or Pixels[Height][Width]

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

原始数据

函数

The whole image as tightly packed RGBA bytes, four per pixel, row by row from the top-left corner; see PixelImage.ToTightlyPackedRgbaBytes.

签名
原始数据(Pixel Image: Pixel Image) -> 字节数组
byte[] Raw(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果字节数组

备注

Every read builds a new copy of the pixel data, so read it once and keep the result rather than reading it inside a loop.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

行数

函数

Height of the image in pixels, that is, the number of rows.

签名
行数(Pixel Image: Pixel Image) -> 整数
int Rows(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果整数

备注

Setting this does not resize PixelImage.Pixels; it should match the number of rows in the pixel data.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

获取颜色

函数

The color of one pixel, exactly as stored.

签名
获取颜色(Pixel Image: Pixel Image, X: 整数, Y: 整数) -> 颜色
ColorElement GetColor(PixelImage Pixel Image, int x, int y)

参数

名称类型默认值说明
Pixel ImagePixel Image—
X整数—Column, counted from 0 at the left edge.
Y整数—Row, counted from 0 at the top edge.

返回

结果颜色
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

获取浮点值

函数

The pixel's value read as a single number from 0 to 1, taken from its red channel alone; useful for heightmaps, masks and other grayscale data.

签名
获取浮点值 -> 低精度数字
    Pixel Image: Pixel Image
    X: 整数
    Y: 整数
float GetFloatValue(PixelImage Pixel Image, int x, int y)

参数

名称类型默认值说明
Pixel ImagePixel Image—
X整数—Column, counted from 0 at the left edge.
Y整数—Row, counted from 0 at the top edge.

返回

结果低精度数字
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

获取灰度字节

函数

The pixel's value read as grayscale, which for this image is its red channel alone (green, blue and alpha are ignored).

签名
获取灰度字节(Pixel Image: Pixel Image, X: 整数, Y: 整数) -> 字节
byte GetGrayByte(PixelImage Pixel Image, int x, int y)

参数

名称类型默认值说明
Pixel ImagePixel Image—
X整数—Column, counted from 0 at the left edge.
Y整数—Row, counted from 0 at the top edge.

返回

结果字节
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

获取像素

函数

The color of one pixel.

签名
获取像素(Pixel Image: Pixel Image, X: 整数, Y: 整数) -> 颜色
ColorElement GetPixel(PixelImage Pixel Image, int x, int y)

参数

名称类型默认值说明
Pixel ImagePixel Image—
X整数—Column, counted from 0 at the left edge.
Y整数—Row, counted from 0 at the top edge.

返回

结果颜色
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

获取 PNG 缓冲区

函数

重载 1/2

签名
获取 PNG 缓冲区(Pixel Image: Pixel Image) -> 字节数组
byte[] GetPngBuffer(PixelImage Pixel Image)

Serialize image as raw PNG file buffer. Supports large images.

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果字节数组

重载 2/2

签名
获取 PNG 缓冲区 -> 字节数组
    Pixel Image: Pixel Image
    选项: Png Image Writer Options
byte[] GetPngBuffer(
    PixelImage Pixel Image,
    PngImageWriterOptions options)

Serialize image as raw PNG file buffer, with explicit encoder options. Supports large images.

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Png Image Writer Options—

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存

函数

重载 1/3

签名
保存(Pixel Image: Pixel Image, 路径: 文本)
void Save(PixelImage Pixel Image, string path)

Writes image as PNG to target file path.
This supports large pngs.

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—

备注

Encoding is delegated to BuiltinIO.PngImageWriter, which streams row by row and picks
the smallest lossless colour type for the pixel data.

重载 2/3

签名
保存
    Pixel Image: Pixel Image
    路径: 文本
    选项: Png Image Writer Options
void Save(
    PixelImage Pixel Image,
    string path,
    PngImageWriterOptions options)

Writes image as PNG to target file path, with explicit encoder options.

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Png Image Writer Options—

重载 3/3

签名
保存(Pixel Image: Pixel Image, 流式输出: Stream)
void Save(PixelImage Pixel Image, Stream stream)

Writes this image as PNG to a stream.

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 BMP

函数

Writes the image as a Windows bitmap (.bmp).

签名
保存为 BMP
    Pixel Image: Pixel Image
    路径: 文本
    选项: Bmp Image Writer Options
void SaveAsBmp(
    PixelImage Pixel Image,
    string path,
    BmpImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Bmp Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 GIF

函数

Writes the image as GIF. Alpha collapses to the format's single transparent index.

签名
保存为 GIF
    Pixel Image: Pixel Image
    路径: 文本
    选项: Gif Image Writer Options
void SaveAsGif(
    PixelImage Pixel Image,
    string path,
    GifImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Gif Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 ICO

函数

Writes the image as a Windows icon (.ico).

签名
保存为 ICO
    Pixel Image: Pixel Image
    路径: 文本
    选项: Ico Image Writer Options
void SaveAsIco(
    PixelImage Pixel Image,
    string path,
    IcoImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Ico Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 JPEG

函数

Writes the image as baseline JPEG (.jpg). Lossy, and transparency is composited away.

签名
保存为 JPEG
    Pixel Image: Pixel Image
    路径: 文本
    选项: Jpeg Image Writer Options
void SaveAsJpeg(
    PixelImage Pixel Image,
    string path,
    JpegImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Jpeg Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 PNM

函数

Writes the image as Netpbm (.ppm/.pgm/.pbm). Alpha is discarded.

签名
保存为 PNM
    Pixel Image: Pixel Image
    路径: 文本
    选项: Portable Any Map Image Writer Options
void SaveAsPortableAnyMap(
    PixelImage Pixel Image,
    string path,
    PortableAnyMapImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Portable Any Map Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 PFM

函数

Writes the image as Portable FloatMap (.pfm), converting channels to 32-bit float.

签名
保存为 PFM
    Pixel Image: Pixel Image
    路径: 文本
    选项: Portable Float Map Image Writer Options
void SaveAsPortableFloatMap(
    PixelImage Pixel Image,
    string path,
    PortableFloatMapImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Portable Float Map Image Writer Options—

备注

PFM is a linear format, so by default the sRGB curve is decoded on the way in. Set
PortableFloatMapImageWriterOptions.SourceTransferFunction to
ColorTransferFunction.Linear for data that is already linear, such as a
depth buffer or heightmap - it is also considerably faster.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 QOI

函数

Writes the image as Quite OK Image (.qoi) - lossless, and much faster to encode than PNG.

签名
保存为 QOI
    Pixel Image: Pixel Image
    路径: 文本
    选项: Qoi Image Writer Options
void SaveAsQoi(
    PixelImage Pixel Image,
    string path,
    QoiImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Qoi Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为文本

函数

The image as Base64 text, encoding the same bytes as PixelImage.SerializeIntoBytes, for storing an image inside a text document.

签名
保存为文本(Pixel Image: Pixel Image) -> 文本
string SaveAsText(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果文本
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 TGA

函数

Writes the image as Truevision TGA (.tga), run-length encoded by default.

签名
保存为 TGA
    Pixel Image: Pixel Image
    路径: 文本
    选项: Tga Image Writer Options
void SaveAsTga(
    PixelImage Pixel Image,
    string path,
    TgaImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Tga Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存为 WebP

函数

Writes the image as WebP (.webp): lossless, with alpha stored natively, unless WebPImageWriterOptions.Lossy asks for libwebp's lossy form.

签名
保存为 WebP
    Pixel Image: Pixel Image
    路径: 文本
    选项: Web P Image Writer Options
void SaveAsWebP(
    PixelImage Pixel Image,
    string path,
    WebPImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
路径文本—
选项Web P Image Writer Options—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

序列化为字节

函数

Serializes the image into Divooka's own binary form, as written by PixelImage.WriteToStream.

签名
序列化为字节(Pixel Image: Pixel Image) -> 字节数组
byte[] SerializeIntoBytes(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

设置像素

函数

Replaces the color of one pixel, changing the image in place.

签名
设置像素(Pixel Image: Pixel Image, X: 整数, Y: 整数, 颜色: 颜色)
void SetPixel(
    PixelImage Pixel Image,
    int x,
    int y,
    ColorElement color)

参数

名称类型默认值说明
Pixel ImagePixel Image—
X整数—Column, counted from 0 at the left edge.
Y整数—Row, counted from 0 at the top edge.
颜色颜色—The new color.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 BMP 字节

函数

Encodes the image as a Windows bitmap (.bmp) file in memory, producing the same bytes PixelImage.SaveAsBmp writes to disk.

签名
转为 BMP 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Bmp Image Writer Options
byte[] ToBmpBytes(
    PixelImage Pixel Image,
    BmpImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Bmp Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为平铺数组

函数

Copies all pixels into a single array, row by row from the top-left corner, so pixel (x, y) is at index y * Columns + x.

签名
转为平铺数组(Pixel Image: Pixel Image) -> 颜色数组
ColorElement[] ToFlatArray(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果颜色数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 GIF 字节

函数

Encodes the image as a GIF file in memory, producing the same bytes PixelImage.SaveAsGif writes to disk.

签名
转为 GIF 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Gif Image Writer Options
byte[] ToGifBytes(
    PixelImage Pixel Image,
    GifImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Gif Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 ICO 字节

函数

Encodes the image as a Windows icon (.ico) file in memory, producing the same bytes PixelImage.SaveAsIco writes to disk.

签名
转为 ICO 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Ico Image Writer Options
byte[] ToIcoBytes(
    PixelImage Pixel Image,
    IcoImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Ico Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 JPEG 字节

函数

Encodes the image as a baseline JPEG (.jpg) file in memory, producing the same bytes PixelImage.SaveAsJpeg writes to disk.

签名
转为 JPEG 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Jpeg Image Writer Options
byte[] ToJpegBytes(
    PixelImage Pixel Image,
    JpegImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Jpeg Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 PNM 字节

函数

Encodes the image as a Netpbm (.ppm/.pgm/.pbm) file in memory, producing the same bytes PixelImage.SaveAsPortableAnyMap writes to disk.

签名
转为 PNM 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Portable Any Map Image Writer Options
byte[] ToPortableAnyMapBytes(
    PixelImage Pixel Image,
    PortableAnyMapImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Portable Any Map Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 PFM 字节

函数

Encodes the image as a Portable FloatMap (.pfm) file in memory, producing the same bytes PixelImage.SaveAsPortableFloatMap writes to disk.

签名
转为 PFM 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Portable Float Map Image Writer Options
byte[] ToPortableFloatMapBytes(
    PixelImage Pixel Image,
    PortableFloatMapImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Portable Float Map Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 QOI 字节

函数

Encodes the image as a Quite OK Image (.qoi) file in memory, producing the same bytes PixelImage.SaveAsQoi writes to disk.

签名
转为 QOI 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Qoi Image Writer Options
byte[] ToQoiBytes(
    PixelImage Pixel Image,
    QoiImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Qoi Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 TGA 字节

函数

Encodes the image as a Truevision TGA (.tga) file in memory, producing the same bytes PixelImage.SaveAsTga writes to disk.

签名
转为 TGA 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Tga Image Writer Options
byte[] ToTgaBytes(
    PixelImage Pixel Image,
    TgaImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Tga Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为紧凑 RGBA 字节

函数

Low-level interop conversion.

签名
转为紧凑 RGBA 字节(Pixel Image: Pixel Image) -> 字节数组
byte[] ToTightlyPackedRgbaBytes(PixelImage Pixel Image)

参数

名称类型默认值说明
Pixel ImagePixel Image—

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

转为 WebP 字节

函数

Encodes the image as a WebP (.webp) file in memory, producing the same bytes PixelImage.SaveAsWebP writes to disk.

签名
转为 WebP 字节 -> 字节数组
    Pixel Image: Pixel Image
    选项: Web P Image Writer Options
byte[] ToWebPBytes(
    PixelImage Pixel Image,
    WebPImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
选项Web P Image Writer Options—Encoder settings; null uses the defaults.

返回

结果字节数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

更新颜色数据

函数

Replaces the image's pixel rows with whatever the updater returns, given the current rows.

签名
更新颜色数据
    Pixel Image: Pixel Image
    更新函数: Func<颜色数组数组, 颜色数组数组>
void UpdateColorData(
    PixelImage Pixel Image,
    Func<ColorElement[][], ColorElement[][]> updater)

参数

名称类型默认值说明
Pixel ImagePixel Image—
更新函数Func<颜色数组数组, 颜色数组数组>—A function from the current [row][column] pixel grid to the new one.

备注

The updater receives the live pixel array, not a copy, so it may edit it in place and return it. PixelImage.Columns and PixelImage.Rows are not changed, so the returned grid should keep the same size.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 BMP

函数

Encodes the image as a Windows bitmap (.bmp) file into a stream, starting at its current position; the stream is left open.

签名
写入 BMP
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Bmp Image Writer Options
void WriteBmp(
    PixelImage Pixel Image,
    Stream stream,
    BmpImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Bmp Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 GIF

函数

Encodes the image as a GIF file into a stream, starting at its current position; the stream is left open.

签名
写入 GIF
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Gif Image Writer Options
void WriteGif(
    PixelImage Pixel Image,
    Stream stream,
    GifImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Gif Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 ICO

函数

Encodes the image as a Windows icon (.ico) file into a stream, starting at its current position; the stream is left open.

签名
写入 ICO
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Ico Image Writer Options
void WriteIco(
    PixelImage Pixel Image,
    Stream stream,
    IcoImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Ico Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 JPEG

函数

Encodes the image as a baseline JPEG (.jpg) file into a stream, starting at its current position; the stream is left open.

签名
写入 JPEG
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Jpeg Image Writer Options
void WriteJpeg(
    PixelImage Pixel Image,
    Stream stream,
    JpegImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Jpeg Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 PNM

函数

Encodes the image as a Netpbm (.ppm/.pgm/.pbm) file into a stream, starting at its current position; the stream is left open.

签名
写入 PNM
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Portable Any Map Image Writer Options
void WritePortableAnyMap(
    PixelImage Pixel Image,
    Stream stream,
    PortableAnyMapImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Portable Any Map Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 PFM

函数

Encodes the image as a Portable FloatMap (.pfm) file into a stream, starting at its current position; the stream is left open.

签名
写入 PFM
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Portable Float Map Image Writer Options
void WritePortableFloatMap(
    PixelImage Pixel Image,
    Stream stream,
    PortableFloatMapImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Portable Float Map Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 QOI

函数

Encodes the image as a Quite OK Image (.qoi) file into a stream, starting at its current position; the stream is left open.

签名
写入 QOI
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Qoi Image Writer Options
void WriteQoi(
    PixelImage Pixel Image,
    Stream stream,
    QoiImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Qoi Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 TGA

函数

Encodes the image as a Truevision TGA (.tga) file into a stream, starting at its current position; the stream is left open.

签名
写入 TGA
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Tga Image Writer Options
void WriteTga(
    PixelImage Pixel Image,
    Stream stream,
    TgaImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Tga Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入流

函数

Writes the image in Divooka's binary form: four 32-bit integers (format version 1, width, height, payload length in bytes) followed by the tightly packed RGBA pixels, row by row from the top.

签名
写入流(Pixel Image: Pixel Image, 写入器: BinaryWriter) -> 大整数
long WriteToStream(PixelImage Pixel Image, BinaryWriter writer)

参数

名称类型默认值说明
Pixel ImagePixel Image—
写入器BinaryWriter—The writer to append to.

返回

结果大整数
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

写入 WebP

函数

Encodes the image as a WebP (.webp) file into a stream, starting at its current position; the stream is left open.

签名
写入 WebP
    Pixel Image: Pixel Image
    流式输出: Stream
    选项: Web P Image Writer Options
void WriteWebP(
    PixelImage Pixel Image,
    Stream stream,
    WebPImageWriterOptions options)

参数

名称类型默认值说明
Pixel ImagePixel Image—
流式输出Stream—A writable stream to receive the file.
选项Web P Image Writer Options—Encoder settings; null uses the defaults.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

分配像素

函数

Allocates a new [row][column] pixel grid of the given size, filled with one color.

签名
分配像素(宽度: 整数, 高度: 整数, 颜色: 可选颜色) -> 颜色数组数组
ColorElement[][] AllocatePixels(
    int width,
    int height,
    ColorElement? color)

参数

名称类型默认值说明
宽度整数—Number of pixels in each row.
高度整数—Number of rows.
颜色可选颜色—The fill color; null leaves every pixel transparent black (all channels 0).

返回

结果颜色数组数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从平铺数组生成

函数

Creates an image from a single array of pixels laid out row by row from the top-left corner, the inverse of PixelImage.ToFlatArray.

签名
从平铺数组生成 -> Pixel Image
    宽度: 整数
    高度: 整数
    平面值: 颜色数组
PixelImage FromFlatArray(
    int width,
    int height,
    ColorElement[] flat)

参数

名称类型默认值说明
宽度整数—Number of columns, in pixels.
高度整数—Number of rows, in pixels.
平面值颜色数组—Exactly Width × Height pixels; the first Width are the top row.

返回

结果Pixel Image

备注

The pixels are copied, so later changes to Flat do not affect the image.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从打包整数像素生成

函数

Creates an image from rows of 32-bit packed pixels, one uint per pixel, indexed [row][column].

签名
从打包整数像素生成(打包像素: 正整数数组数组) -> Pixel Image
PixelImage FromPackedIntPixels(uint[][] packedPixels)

参数

名称类型默认值说明
打包像素正整数数组数组—The packed pixels, row-major, every row as long as the first.

返回

结果Pixel Image

备注

Each value is split into bytes in the machine's byte order and read as red, green, blue, alpha, so on little-endian hardware the lowest byte is red and the highest is alpha (0xAABBGGRR). The width is taken from the first row, and the values are copied into a new pixel grid.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从打包 RGBA 字节生成

函数

重载 1/2

签名
从打包 RGBA 字节生成 -> Pixel Image
    宽度: 整数
    高度: 整数
    原始字节: 字节数组
PixelImage FromPackedRGBABytes(
    int width,
    int height,
    byte[] rawBytes)

Creates an image from tightly packed RGBA bytes, four per pixel (red, green, blue, alpha), row by row from the top-left corner with no padding.

参数

名称类型默认值说明
宽度整数—Number of columns, in pixels.
高度整数—Number of rows, in pixels.
原始字节字节数组—Exactly Width × Height × 4 bytes.

返回

结果Pixel Image

备注

The bytes are copied, so later changes to Raw Bytes do not affect the image. A height of 0 gives an empty image.

重载 2/2

签名
从打包 RGBA 字节生成 -> Pixel Image
    RGBA: 字节数组
    宽度: 整数
    高度: 整数
PixelImage FromPackedRGBABytes(
    byte[] rgba,
    int width,
    int height)

Legacy overload; Pending consolidation.

参数

名称类型默认值说明
RGBA字节数组—
宽度整数—
高度整数—

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从 URI 加载

函数

Loads an image from a file path or a web address, in any format PixelImage.LoadFromFile accepts.

签名
从 URI 加载(URI: Uri) -> Pixel Image
PixelImage FromUri(Uri uri)

参数

名称类型默认值说明
URIUri—A relative path, a file URI, or an http/https URL.

返回

结果Pixel Image

备注

A relative URI is resolved against the current working directory and a file URI is read from disk. An http or https URI is downloaded in full, synchronously, before decoding.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

获取临时图像路径

函数

此节点没有文档说明。

签名
获取临时图像路径() -> 文本
string GetTempImagePath()

返回

结果文本

备注

Should only be used for really getting a temp image path and no longer used for conversion.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

初始化黑色图像

函数

Initialize image with some color

签名
初始化黑色图像 -> Pixel Image
    宽度: 整数
    高度: 整数
    颜色: 可选颜色
PixelImage InitializeBlackImage(
    int width,
    int height,
    ColorElement? color)

参数

名称类型默认值说明
宽度整数—
高度整数—
颜色可选颜色—

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从字节初始化

函数

Rebuilds an image from bytes produced by PixelImage.SerializeIntoBytes.

签名
从字节初始化(数据: 字节数组) -> Pixel Image
PixelImage InitializeFromBytes(byte[] data)

参数

名称类型默认值说明
数据字节数组—The serialized image.

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从文件加载

函数

Load from PNG file.
In reality, supports wider range of input options than PixelImage.LoadFromFile.

签名
从文件加载(路径: 文本) -> Pixel Image
PixelImage LoadFromFile(string path)

参数

名称类型默认值说明
路径文本—

返回

结果Pixel Image

备注

Though officially we support only PNG file on Image.PixelImage; In practice this can load more than that.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从文件缓冲区加载

函数

此节点没有文档说明。

签名
从文件缓冲区加载(文件数据: 字节数组) -> Pixel Image
PixelImage LoadFromFileBuffer(byte[] fileData)

参数

名称类型默认值说明
文件数据字节数组—Png, jpg, bmp, webp... Anything you like!

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从文本加载

函数

Rebuilds an image from Base64 text produced by PixelImage.SaveAsText.

签名
从文本加载(文本: 文本) -> Pixel Image
PixelImage LoadFromText(string text)

参数

名称类型默认值说明
文本文本—The Base64 text.

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从文件缓冲区加载打包 RGBA

函数

Decodes an image straight to tightly packed RGBA bytes, row zero first, without building
a Image.PixelImage on the way.

签名
从文件缓冲区加载打包 RGBA(文件数据: 字节数组) -> (结果: 字节数组, 宽度: 整数, 高度: 整数)
byte[] LoadPackedRgbaFromFileBuffer(
    byte[] fileData,
    out int width,
    out int height)

参数

名称类型默认值说明
文件数据字节数组—Png, jpg, bmp, webp... Anything PixelImage.LoadFromFileBuffer takes.

返回

结果字节数组
宽度整数
高度整数
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

从流读取

函数

Reads an image written by PixelImage.WriteToStream, leaving the reader just past it.

签名
从流读取(读取器: BinaryReader) -> (结果: 大整数, 值: Pixel Image)
long ReadFromStream(BinaryReader reader, out PixelImage value)

参数

名称类型默认值说明
读取器BinaryReader—The reader positioned at the image.

返回

结果大整数
值Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理

保存原始数据

函数

Compact fast raw data dump that writes a tiny header (magic + version + width + height) followed by tightly packed RGBA bytes for every pixel in row-major order.

签名
保存原始数据
    路径: 文本
    像素: 颜色数组数组
    宽度: 整数
    高度: 整数
void SaveRaw(
    string path,
    ColorElement[][] pixels,
    int width,
    int height)

参数

名称类型默认值说明
路径文本—
像素颜色数组数组—
宽度整数—
高度整数—

备注

It uses MemoryMarshal.AsBytes so we avoid per-pixel copying.

### Format summary

**Header (9 bytes total):**
* `PXLR` (ASCII)
* `1` (byte: format version)
* `width` (Int32, little-endian)
* `height` (Int32, little-endian)

**Data:** `height` rows × `width` pixels × **4 bytes per pixel** (R, G, B, A), no padding.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
像素图像
所属包
图像处理