ImagePixelFormat

ImagePixelFormat enumeration

指定生成的文档页面图像的像素格式。

public enum ImagePixelFormat

价值观

姓名价值描述
Format16BppRgb5550每像素 16 位,RGB。
Format16BppRgb5651每像素 16 位,RGB。
Format16BppArgb15552每像素 16 位,ARGB。
Format24BppRgb3每像素 24 位,RGB。
Format32BppRgb4每像素 32 位,RGB。
Format32BppArgb5每像素 32 位,ARGB。
Format32BppPArgb6每像素 32 位,ARGB,预乘 alpha。
Format48BppRgb7每像素 48 位,RGB。
Format64BppArgb8每像素 64 位,ARGB。
Format64BppPArgb9每像素 64 位,ARGB,预乘 alpha。
Format1bppIndexed10每像素 1 位,索引。

例子

展示如何选择将文档渲染为图像的每像素位数。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.ParagraphFormat.Style = doc.Styles["Heading 1"];
builder.Writeln("Hello world!");
builder.InsertImage(ImageDir + "Logo.jpg");

// 当我们将文档保存为图像时,我们可以将 SaveOptions 对象传递给
// 为保存操作将生成的图像选择像素格式。
// 不同的每像素比特率将影响生成图像的质量和文件大小。
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.Png);
imageSaveOptions.PixelFormat = imagePixelFormat;

// 我们可以克隆 ImageSaveOptions 实例。
Assert.AreNotEqual(imageSaveOptions, imageSaveOptions.Clone());

doc.Save(ArtifactsDir + "ImageSaveOptions.PixelFormat.png", imageSaveOptions);

也可以看看