Class WmfImage

Class WmfImage

名称: Aspose.Imaging.FileFormats.Wmf 收藏: Aspose.Imaging.dll (25.4.0)

使用我们的 API 无缝操纵 Microsoft Windows Metafile (WMF) 图像处理在变量长记录中存储的 vector 和 bitmap 数据。轻松重定向、旋转和滑动图像,同时设置自定义图像板。将 WMF 文件转换为压缩的 WMZ 格式或将其存储在 Raster 图像格式中可在平台和应用程序中多元化使用。

[JsonObject(MemberSerialization.OptIn)]
public class WmfImage : MetaImage, IDisposable, IObjectWithBounds, IObjectWithSizeF

Inheritance

object DisposableObject DataStreamSupporter Image VectorImage MetaImage WmfImage

Implements

IDisposable , IObjectWithBounds , IObjectWithSizeF

继承人

MetaImage.GetUsedFonts() , MetaImage.GetMissedFonts() , MetaImage.ResizeCanvas(Rectangle) , MetaImage.GetCanNotSaveMessage(ImageOptionsBase) , MetaImage.SaveData(Stream) , MetaImage.Records , VectorImage.GetEmbeddedImages() , VectorImage.RemoveBackground() , VectorImage.RemoveBackground(RemoveBackgroundSettings) , VectorImage.Resize(int, int, ResizeType) , VectorImage.Resize(int, int, ImageResizeSettings) , VectorImage.RotateFlip(RotateFlipType) , VectorImage.Crop(Rectangle) , VectorImage.Rotate(float) , VectorImage.Modify(RectangleF, float, float, float) , VectorImage.SizeF , VectorImage.WidthF , VectorImage.HeightF , VectorImage.Width , VectorImage.Height , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.UpdateContainer(Image) , Image.GetCanNotSaveMessage(ImageOptionsBase) , Image.GetFitRectangle(Rectangle) , Image.GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter) , Image.GetFitRectangle(Rectangle, int[]) , Image.OnPaletteChanged(IColorPalette, IColorPalette) , Image.OnPaletteChanging(IColorPalette, IColorPalette) , Image.ReleaseManagedResources() , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.timeout , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.SaveData(Stream) , DataStreamSupporter.ReleaseManagedResources() , DataStreamSupporter.OnDataStreamContainerChanging(StreamContainer) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

下面的例子显示如何将wmz图像转换为wmf图像

string file = "example.wmz";
                                                                                string baseFolder = System.IO.Path.Combine("D:", "Compressed");
                                                                                string inputFile = System.IO.Path.Combine(baseFolder, file);
                                                                                string outFile = inputFile + ".wmf";
                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
                                                                                {
                                                                                    Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions() { PageSize = image.Size};
                                                                                    image.Save(outFile, new Aspose.Imaging.ImageOptions.WmfOptions() {VectorRasterizationOptions = vectorRasterizationOptions});
                                                                                }

下面的例子显示如何将 wmf 图像转换为 wmz fromat

string file = "castle.wmf";
                                                                                string baseFolder = System.IO.Path.Combine("D:", "Compressed");
                                                                                string inputFile = System.IO.Path.Combine(baseFolder, file);
                                                                                string outFile = inputFile + ".wmz";
                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
                                                                                {
                                                                                    Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions() { PageSize = image.Size};
                                                                                    image.Save(outFile, new Aspose.Imaging.ImageOptions.WmfOptions() {VectorRasterizationOptions = vectorRasterizationOptions, Compress = true});
                                                                                }

下面的示例显示如何转换压缩图像(.emz ,.wmz, *.svgz) 到 raster fromat

string[] files = new[] {"example.emz", "example.wmz", "example.svgz"};
                                                                                                                string baseFolder = System.IO.Path.Combine("D:","Compressed");
                                                                                                                foreach (var file in files)
                                                                                                                {
                                                                                                                    string inputFile = System.IO.Path.Combine(baseFolder, file);
                                                                                                                    string outFile = inputFile + ".png";
                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = (Aspose.Imaging.ImageOptions.VectorRasterizationOptions)image.GetDefaultOptions(new object[] { Color.White, image.Width, image.Height });
                                                                                                                        image.Save(outFile, new Aspose.Imaging.ImageOptions.PngOptions(){VectorRasterizationOptions = vectorRasterizationOptions});
                                                                                                                    }
                                                                                                                }

此示例显示如何从文件上传 WMF 图像并使用 WmfRasterizationOptions 将其转换为 SVG。

string dir = "c:\\temp\\";

                                                                                                                      // Using Aspose.Imaging.Image.Load is a unified way to load all types of images including WMF.
                                                                                                                      using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = (Aspose.Imaging.FileFormats.Wmf.WmfImage)Aspose.Imaging.Image.Load(dir + "test.wmf"))
                                                                                                                      {
                                                                                                                          Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();

                                                                                                                          // Text will be converted to shapes.
                                                                                                                          saveOptions.TextAsShapes = true;

                                                                                                                          Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();

                                                                                                                          // The background color of the drawing surface.
                                                                                                                          rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;

                                                                                                                          // The page size.
                                                                                                                          rasterizationOptions.PageSize = wmfImage.Size;

                                                                                                                          // If embedded emf exists, then render emf; otherwise render wmf.
                                                                                                                          rasterizationOptions.RenderMode = Aspose.Imaging.FileFormats.Wmf.WmfRenderMode.Auto;

                                                                                                                          saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                          wmfImage.Save(dir + "test.output.svg", saveOptions);
                                                                                                                      }

Constructors

WmfImage()

创建 Aspose.Imaging.FileFormats.Wmf.WmfImage 类的新例子,启动它为更多操作和处理 Windows Metafile (WMF) 图像数据。建筑师提供与WMF图像合作的基本对象,可WMF图像处理能力无缝集成到您的应用程序中功能性。

[JsonConstructor]
public WmfImage()

WmfImage(int , int , int)

启动 Aspose.Imaging.FileFormats.Wmf.WmfImage 类的新示例,可自定义宽度和高度参数,促进白色WMF图像的创建适用于特定的尺寸. 使用此构建器以动态生成WMF 精确尺寸的图像,可灵活的图像创建和在您的应用中进行操纵。

public WmfImage(int width, int height)

Parameters

width int

宽度。

height int

身高。

Properties

BitsPerPixel

恢复图像每像素的比特数,显示颜色水平深度或深度. 使用此属性来确定图像的颜色代表性和准确性,促进兼容性检查和与颜色相关的在您的申请中进行处理。

[JsonIgnore]
public override int BitsPerPixel { get; }

财产价值

int

Exceptions

NotImplementedException

FileFormat

访问与图像相关的文件格式值,提供信息关于图像存储的格式. 使用此属性来确定图像的文件格式,方便兼容性检查和在您的应用程序内进行格式特定的处理。

public override FileFormat FileFormat { get; }

财产价值

FileFormat

FrameBounds

接入框架的边界,指示其位置和尺寸在使用此属性获取有关框架的详细信息空间位置,允许在您的应用程序中准确的操作和播放。

public Rectangle FrameBounds { get; }

财产价值

Rectangle

高F

访问图像的高度,代表其垂直的像素数量使用此属性来确定图像的空间尺寸和外观比例,允许准确的布局和在您的应用程序内进行调整。

public override float HeightF { get; }

财产价值

float

Exceptions

NotImplementedException

Inch

访问或修改英寸属性,代表测量单位通常用于在印刷或显示背景中指定物理尺寸。与图像相关的英寸值设立或获取的属性,便于在您的应用中准确地描述物理尺寸。

public int Inch { get; set; }

财产价值

int

IsCached

恢复一个 boolean 值,表明对象的数据是否目前被隐藏,消除需要额外的数据阅读操作。通过确定对象的数据是否容易可用来优化性能无需在您的申请中进行昂贵的数据获取过程。

public override bool IsCached { get; }

财产价值

bool

Exceptions

NotImplementedException

WidthF

访问图像的宽度,指示图像的长度使用此属性来确定图像的空间尺寸和方面比例,允许准确的布局和在您的内部进行调整应用。

public override float WidthF { get; }

财产价值

float

Exceptions

NotImplementedException

Methods

AddRecord(WmfObject)

将指定的记录对象纳入图像中,丰富其内容额外的数据或代数据. 使用此方法无缝集成记录物体进入图像,方便全面的数据存储和组织在您的申请中。

public int AddRecord(WmfObject record)

Parameters

record WmfObject

记录的。

Returns

int

记录数。

CacheData()

有效地存储数据,消除需要额外的加载基于 Aspose.Imaging.DataStreamSupporter.DataStreamContainer. 使用此方法,以优化性能,并在您的应用程序中尽量减少资源使用通过存储和访问本地数据库。

public override void CacheData()

Examples

此示例显示如何从文件中加载 WMF 图像,并列出其所有记录。

string dir = "c:\\temp\\";

                                                                                              // Using Aspose.Imaging.Image.Load is a unified way to load all types of images including WMF.
                                                                                              using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = (Aspose.Imaging.FileFormats.Wmf.WmfImage)Aspose.Imaging.Image.Load(dir + "test.wmf"))
                                                                                              {
                                                                                                  // Cache data to load all records.
                                                                                                  wmfImage.CacheData();
                                                                                                  System.Console.WriteLine("The total number of records: {0}", wmfImage.Records.Count);

                                                                                                  // The key is a record type, the value is number of records of that type in the WMF image.
                                                                                                  System.Collections.Generic.Dictionary<system.type, int=""> types =
                                                                                                      new System.Collections.Generic.Dictionary<system.type, int="">();

                                                                                                  // Gather statistics 
                                                                                                  foreach (Aspose.Imaging.FileFormats.Wmf.Objects.WmfObject obj in wmfImage.Records)
                                                                                                  {
                                                                                                      System.Type objType = obj.GetType();
                                                                                                      if (!types.ContainsKey(objType))
                                                                                                      {
                                                                                                          types.Add(objType, 1);
                                                                                                      }
                                                                                                      else
                                                                                                      {
                                                                                                          types[objType]++;
                                                                                                      }
                                                                                                  }

                                                                                                  // Print statistics
                                                                                                  System.Console.WriteLine("Record Type                              Count");
                                                                                                  System.Console.WriteLine("----------------------------------------------");
                                                                                                  foreach (System.Collections.Generic.KeyValuePair<system.type, int=""> entry in types)
                                                                                                  {
                                                                                                      string objectType = entry.Key.Name;
                                                                                                      string alignmentGap = new string(' ', 40 - objectType.Length);
                                                                                                      System.Console.WriteLine("{0}:{1}{2}", entry.Key.Name, alignmentGap, entry.Value);
                                                                                                  }
                                                                                              }

                                                                                              //The output may look like this:
                                                                                              //The total number of records: 613
                                                                                              //Record Type                              Count
                                                                                              //----------------------------------------------
                                                                                              //WmfSetBkMode:                            1
                                                                                              //WmfSetTextAlign:                         1
                                                                                              //WmfSetRop2:                              1
                                                                                              //WmfSetWindowOrg:                         1
                                                                                              //WmfSetWindowExt:                         1
                                                                                              //WmfCreateBrushInDirect:                  119
                                                                                              //WmfSelectObject:                         240
                                                                                              //WmfCreatePenInDirect:                    119
                                                                                              //WmfSetPolyFillMode:                      1
                                                                                              //WmfPolyPolygon:                          114
                                                                                              //WmfPolyLine:                             7
                                                                                              //WmfSetTextColor:                         2
                                                                                              //WmfCreateFontInDirect:                   2
                                                                                              //WmfExtTextOut:                           2
                                                                                              //WmfDibStrechBlt:                         1
                                                                                              //WmfEof:                                  1</system.type,></system.type,></system.type,>

Exceptions

NotImplementedException

GetDefaultOptions(对象[])

修复与图像相关的默认选项,提供访问默认设置或设置. 使用此方法访问默认设置图像处理操作的设置,促进一致性和方便性在您的应用程序的功能范围内。

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object ( )

这些论点。

Returns

ImageOptionsBase

默认选项

GetOriginalOptions()

获取原始图像选项。

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

原始图像选项

GetPostScript()

访问与图像相关的 PostScript 数据,提供详细信息关于其结构或内容的信息. 使用此方法获取在您的应用程序中进行进一步分析或处理的 PostScript 数据,提供与 PostScript 播放或操纵相关的先进功能。

public string GetPostScript()

Returns

string

邮政脚本

GetUsedFonts()

恢复在代码中使用的字体列表,提供洞察到图像中使用的字体资源 使用此方法来分析字体使用并确保字体可用性,以便在您的应用程序中进行交付或进一步处理。

public override string[] GetUsedFonts()

Returns

string ( )

字体列表

ResizeCanvas(Rectangle)

重新调整图像的容器,同时保持图像的尺寸使用此方法来改变管道的大小而不改变管道的尺寸。内容,方便布局调整和组成变化在您的内部应用。

public override void ResizeCanvas(Rectangle newRectangle)

Parameters

newRectangle Rectangle

新直角。

Exceptions

NotImplementedException

SetPalette(彩色 彩色 彩色)

将特定的板块应用到图像中,使颜色可自定义使用此方法,提高视觉表现和具体的颜色效应在您的应用中。

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

要安排的板块。

updateColors bool

如果设置为“真实”颜色,将根据新板更新;否则颜色指数仍然不变. 请注意,如果某些指数有不匹配的板输入,不变的指数可能会破坏上载的图像。

Exceptions

NotImplementedException

 中文