Image.Create

Create(ImageOptionsBase, int, int)

使用指定的创建选项创建新图像。

public static Image Create(ImageOptionsBase imageOptions, int width, int height)
参数类型描述
imageOptionsImageOptionsBase图像选项。
宽度Int32宽度。
高度Int32高度。

返回值

新创建的图像。

示例

此示例在磁盘的某个位置创建一个新 Image 文件,位置由 BmpOptions 实例的 Source 属性指定。在创建实际图像之前,设置了 BmpOptions 实例的多个属性。尤其是此情况下指向实际磁盘位置的 Source 属性。

[C#]

//创建 BmpOptions 的实例并设置其各种属性
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;

//创建 FileCreateSource 的实例并将其指定为 BmpOptions 实例的 Source
//第二个 Boolean 参数决定要创建的文件是否为 IsTemporal
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\output.bmp", false);

//通过调用 Create 方法创建 Image 实例并使用 BmpOptions 实例进行初始化。
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
    //进行一些图像处理

    // 保存所有更改
    image.Save();
}

另请参见


Create(ImageOptionsBase, int, int, int[])

从提供的像素数组创建一个 RasterImage 实例。验证指定的宽度和高度是否匹配像素数据的尺寸。此方法只能在库处于 Licensed 模式时使用。

public static Image Create(ImageOptionsBase imageOptions, int width, int height, int[] pixels)
参数类型描述
imageOptionsImageOptionsBase用于创建 RasterImage 的选项。
widthInt32RasterImage 的宽度。
heightInt32RasterImage 的高度。
像素Int32[]用于填充图像的像素值数组。

返回值

一个使用提供的像素数据填充的 RasterImage

异常

异常条件
ImageCreateException如果图像尺寸与像素数组的大小不匹配,或者由于指定的 imageOptions 导致图像创建失败,亦或在库未处于 Licensed 模式时调用此方法,则会抛出异常。

另请参见


Create(Image[])

使用指定的图像作为页面创建新图像

public static Image Create(Image[] images)
参数类型描述
imagesImage[]这些图像。

返回值

Image 作为 IMultipageImage

另请参见


Create(MultipageCreateOptions)

创建指定的多页创建选项。

public static Image Create(MultipageCreateOptions multipageCreateOptions)
参数类型描述
multipageCreateOptionsMultipageCreateOptions多页创建选项。

返回值

多页图像

另请参见


Create(string[], bool)

创建包含指定文件的多页图像。

public static Image Create(string[] files, bool throwExceptionOnLoadError)
参数类型描述
filesString[]这些文件。
throwExceptionOnLoadErrorBoolean如果设置为 true [在加载错误时抛出异常]。

返回值

多页图像

另请参见


Create(string[])

创建包含指定文件的多页图像。

public static Image Create(string[] files)
参数类型描述
filesString[]这些文件。

返回值

多页图像

另请参见


Create(Image[], bool)

使用指定的图像作为页面创建新图像。

public static Image Create(Image[] images, bool disposeImages)
参数类型描述
imagesImage[]这些图像。
disposeImagesBoolean如果设置为 true [释放图像]。

返回值

Image 作为 IMultipageImage

另请参见