Class EmfImage
名称: Aspose.Imaging.FileFormats.Emf 收藏: Aspose.Imaging.dll (25.4.0)
API for Enhanced Metafile Format (EMF) 维克图像格式支持一个全面的工具在设备独立的图形图像处理以一种方式,同时保留其原始属性。比例、尺寸、颜色和其他图形属性,包括EMF Plus 格式支持和功能,用于挖掘区域,重建管道和图像,旋转,滑动,设置图像板,出口和进口到 APS 设备背景,压缩和转换 EMF 到其他格式,确保多元化的操作和无缝的EMF图像在应用中集成。
[JsonObject(MemberSerialization.OptIn)]
public sealed class EmfImage : MetaImage, IDisposable, IObjectWithBounds, IObjectWithSizeF
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← VectorImage ← MetaImage ← EmfImage
Implements
IDisposable , IObjectWithBounds , IObjectWithSizeF
继承人
MetaImage.GetUsedFonts() , MetaImage.GetMissedFonts() , MetaImage.ResizeCanvas(Rectangle) , 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.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.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.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
下面的例子显示如何将 emz 图像转换为 emf fromat
string file = "example.emz";
string baseFolder = System.IO.Path.Combine("D:", "Compressed");
string inputFile = System.IO.Path.Combine(baseFolder, file);
string outFile = inputFile + ".emf";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
{
Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = new Aspose.Imaging.ImageOptions.EmfRasterizationOptions {PageSize = image.Size};
image.Save(outFile, new Aspose.Imaging.ImageOptions.EmfOptions {VectorRasterizationOptions = vectorRasterizationOptions});
}
下面的例子显示如何将 emf 图像转换为 emz fromat
string file = "input.emf";
string baseFolder = System.IO.Path.Combine("D:", "Compressed");
string inputFile = System.IO.Path.Combine(baseFolder, file);
string outFile = inputFile + ".emz";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
{
Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = new Aspose.Imaging.ImageOptions.EmfRasterizationOptions() { PageSize = image.Size};
image.Save(outFile, new Aspose.Imaging.ImageOptions.EmfOptions() {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});
}
}
此示例显示如何从文件中加载 EMF 图像并使用 EmfRasterizationOptions 将其转换为 SVG。
string dir = "c:\\temp\\";
// Using Aspose.Imaging.Image.Load is a unified way to load all types of images including EMF.
using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = (Aspose.Imaging.FileFormats.Emf.EmfImage)Aspose.Imaging.Image.Load(dir + "test.emf"))
{
Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();
// Text will be converted to shapes.
saveOptions.TextAsShapes = true;
Aspose.Imaging.ImageOptions.EmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.EmfRasterizationOptions();
// The background color of the drawing surface.
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;
// The page size.
rasterizationOptions.PageSize = emfImage.Size;
// If embedded emf exists, then render emf; otherwise render wmf.
rasterizationOptions.RenderMode = Aspose.Imaging.FileFormats.Emf.EmfRenderMode.Auto;
// Set the horizontal margin
rasterizationOptions.BorderX = 50;
// Set the vertical margin
rasterizationOptions.BorderY = 50;
saveOptions.VectorRasterizationOptions = rasterizationOptions;
emfImage.Save(dir + "test.output.svg", saveOptions);
}
Constructors
EmfImage()
开始与EMF图像工作,通过启动一个新的例子Aspose.Imaging.FileFormats.Emf.EmfImage 类 理想的快速嵌入 EMF 图像以方便和效率为您的项目。
[JsonConstructor]
public EmfImage()
EmfImage(int , int , int)
创建 Aspose.Imaging.FileFormats.Emf.EmfImage 类的新例子,指定宽度和高度参数. 这个建筑师简化启动过程EMF 图像具有特定的尺寸,提高您的开发效率工作流。
public EmfImage(int width, int height)
Parameters
width
int
宽度。
height
int
身高。
Properties
BitsPerPixel
恢复比特对像素的计算,特别是拉斯特图像,因为这个参数不适用于 vector 图像. 快速确定像素深度图像用于准确的分析和操作,确保准确的处理图像数据。
public override int BitsPerPixel { get; }
财产价值
Exceptions
不适用于 vector 图像。
FileFormat
访问与对象相关的文件格式值。与对象相关的文件格式,以便顺利处理和兼容性检查:通过获取文件格式来简化工作流轻松的信息。
public override FileFormat FileFormat { get; }
财产价值
Header
用此属性恢复或修改 EMF 甲状腺标题记录。在您的应用程序中有效地管理代码数据,改善您的工作流通过简化访问甲状腺标题信息。
public EmfMetafileHeader Header { get; set; }
财产价值
高F
恢复图像的高度,方便精确的播放和布局调整。到达高度属性确保兼容性和无缝的整合不同的平台和应用程序。
public override float HeightF { get; }
财产价值
IsCached
访问一个值,表明对象的数据是否目前被隐藏,消除需要额外的数据阅读;通过快速提高效率确定是否可用于即时访问的隐藏数据。工作流与流动的数据获取过程。
public override bool IsCached { get; }
财产价值
Records
恢复或修改与对象相关的记录. 有效访问和管理记录收集,以提高数据操作和处理。通过与对象的记录无缝互动,优化工作流。
public override MetaObjectList Records { get; set; }
财产价值
WidthF
访问图像的宽度,为准确提供必需信息快速恢复图像的宽度,以确保兼容性并在各种应用程序和平台内进行适当的配置。
public override float WidthF { get; }
财产价值
Methods
CacheData()
有效地存储数据,防止从底部下载Aspose.Imaging.DataStreamSupporter.DataStreamContainer 使用此方法。在您的应用程序中实现性能和流畅的数据访问,优化资源用于提高响应性。
public override void CacheData()
Examples
此示例显示如何从文件中加载 EMF 图像,并列出其所有记录。
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.Emf.EmfImage emfImage = (Aspose.Imaging.FileFormats.Emf.EmfImage)Aspose.Imaging.Image.Load(dir + "test.emf"))
{
// Cache data to load all records.
emfImage.CacheData();
System.Console.WriteLine("The total number of records: {0}", emfImage.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.Emf.Emf.Records.EmfRecord obj in emfImage.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: 1188
//Record Type Count
//----------------------------------------------
//EmfMetafileHeader: 1
//EmfSetBkMode: 1
//EmfSetTextAlign: 1
//EmfSetRop2: 1
//EmfSetWorldTransform: 1
//EmfExtSelectClipRgn: 1
//EmfCreateBrushIndirect: 113
//EmfSelectObject: 240
//EmfCreatePen: 116
//EmfSetPolyFillMode: 1
//EmfBeginPath: 120
//EmfMoveToEx: 122
//EmfPolyBezierTo16: 36
//EmfLineTo: 172
//EmfCloseFigure: 14
//EmfEndPath: 120
//EmfStrokeAndFillPath: 113
//EmfStrokePath: 7
//EmfSetTextColor: 2
//EmfExtCreateFontIndirectW: 2
//EmfExtTextOutW: 2
//EmfStretchBlt: 1
//EmfEof: 1</system.type,></system.type,></system.type,>
GetDefaultOptions(对象[])
恢复您图像的默认选项,无需努力。可以快速访问预定配置,确保无缝集成和为您的项目提供最佳性能. 适合您的工作流程和通过您的图像实现一致的结果。
public override ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
( )
这些论点。
Returns
默认选项
GetOriginalOptions()
获取原始图像选项。
public override ImageOptionsBase GetOriginalOptions()
Returns
原始图像选项
GetUsedFonts()
用此方法恢复在代码中使用的字体列表。对字体使用的了解,促进有效的字体管理和优化提供增强表现和显示忠诚度的资源。
public override string[] GetUsedFonts()
Returns
string ( )
字体列表
ResizeCanvas(Rectangle)
使用此功能轻松地修复管道,完美调整整体图像的尺寸,而不改变其内容。为不同尺寸的图像无力准备。
public override void ResizeCanvas(Rectangle newRectangle)
Parameters
newRectangle
Rectangle
新直角。
SetPalette(彩色 彩色 彩色)
设置图像板。
public override void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
要安排的板块。
updateColors
bool
如果设置为“真实”颜色,将根据新板更新;否则颜色指数仍然不变. 请注意,如果某些指数没有相应的板输入,不变的指数可能会破坏上载的图像。