Class EmfImage

Class EmfImage

Nom dels espais: Aspose.Imaging.FileFormats.Emf Assemblea: Aspose.Imaging.dll (25.4.0)

L’API per a el format d’imatge de vector Enhanced Metafile Format (EMF) ésUna eina completa per processar imatges gràfiques en un dispositiu independentmanera mentre conserva les seves propietats originals. desenvolupat per mantenirproporcions, dimensions, colors i altres atributs gràfics, que inclouenSuport en format EMF Plus i característiques per a les regions de recanvi, canvas de reciclatgei imatges, rotació, flipping, configuració de paletes d’imatge, exportació i importacióAPS en el context del dispositiu, la compressió i la conversió d’EMF en altres formats.La manipulació versàtil i la integració sense segles de les imatges EMF a través d’aplicacions.

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

Inheritance

object DisposableObject DataStreamSupporter Image VectorImage MetaImage EmfImage

Implements

IDisposable , IObjectWithBounds , IObjectWithSizeF

Membres heretats

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

L’exemple següent mostra com convertir una imatge emz en 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});
                                                                                }

L’exemple següent mostra com convertir una imatge emf a 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});
                                                                                }

L’exemple següent mostra com convertir una imatge compresa (de EMZ,.wmz, *.svgz) per a 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});
                                                                                                                    }
                                                                                                                }

Aquest exemple mostra com carregar una imatge EMF d’un arxiu i convertir-la en SVG utilitzant EmfRasterizationOptions.

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()

Començar a treballar amb les imatges de l’EMF iniciant una nova instància de laAspose.Imaging.FileFormats.Emf. EmfImage classe. Ideal per incorporar ràpidament les imatges EMF enEls teus projectes amb facilitat i eficiència.

[JsonConstructor]
public EmfImage()

EmfImage(Int, Int)

Crear una nova instància de la classe Aspose.Imaging.FileFormats.Emf.EmbImage especificant l’ampladaAquest constructor simplifica el procés d’inicialitzacióImatges EMF amb dimensions específiques, millorant l’eficiència del seu desenvolupamentEl flux de treball.

public EmfImage(int width, int height)

Parameters

width int

La seva amplada.

height int

La seva alçada.

Properties

BitsPerPixel

Retirar el nombre de bit-per-pixel específic per a les imatges de raster, com aquest paràmetreno s’aplica a les imatges de vectors. ràpidament determinar la profunditat del pixel del rasterImatges per a l’anàlisi i manipulació precisos, assegurant el tractament precísDades de la imatge.

public override int BitsPerPixel { get; }

Valor de la propietat

int

Exceptions

NotImplementedException

Invalid per a les imatges vectores.

FileFormat

Accedeix al valor del format de fitxer associat amb l’objecte.format del fitxer associat amb l’objecte per al tractament estricte iControls de compatibilitat. Simplifiqueu el flux de treball recuperant el format de fitxerInformació amb facilitat.

public override FileFormat FileFormat { get; }

Valor de la propietat

FileFormat

Header

Recuperar o modificar el registre de titulació metafil EMF amb aquesta propietat.Gestió eficient de les dades metafil·les dins de la seva aplicació. Millorar el seu flux de treballAmb accés simplificat a la informació metafísica.

public EmfMetafileHeader Header { get; set; }

Valor de la propietat

EmfMetafileHeader

Màxim F

Retirar l’altura de la imatge, facilitant ajustaments de rendiment i layout exactes.L’accés a la propietat d’altura assegura la compatibilitat i la integració sense segell entrediferents plataformes i aplicacions.

public override float HeightF { get; }

Valor de la propietat

float

IsCached

Accés a un valor que indiqui si les dades de l’objecte estan actualitzades,Eliminar la necessitat de llegir dades addicionals. millorar l’eficiència per ràpidamentdeterminar si les dades cache estan disponibles per a l’accés immediat.flux de treball amb processos de recuperació de dades estrictats.

public override bool IsCached { get; }

Valor de la propietat

bool

Records

Recuperar o modificar els registres associats amb l’objecte.Gestió de la recollida de registres per a manipulació i processament de dades millors.Optimitzar el seu flux de treball interactuant sense cap dubte amb els registres de l’objecte.

public override MetaObjectList Records { get; set; }

Valor de la propietat

MetaObjectList

El WidthF

Accés a l’amplada de la imatge, proporcionant informació essencial per a la precisiórendiment i processament. ràpidament recuperar l’amplada de la imatge per garantir la compatibilitati el disseny adequat dins de diverses aplicacions i plataformes.

public override float WidthF { get; }

Valor de la propietat

float

Methods

CacheData()

Efectivament cache les dades i prevenir la càrrega redundant des de la baseAspose.Imaging.DataStreamSupporter.data StreamContainer amb aquest mètode.rendiment i accés ràpid a les dades en la seva aplicació, optimitzant els recursosUtilització per a una millor resposta.

public override void CacheData()

Examples

Aquest exemple mostra com carregar una imatge EMF d’un arxiu i llista tots els seus registres.

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(Objecte[])

Retirar les opcions predefinides per a la seva imatge sense esforç. amb aquesta característica,pot accedir ràpidament a les configuracions preses, assegurant la integració sense segell irendiment òptim per als teus projectes. Ideal per simplificar el teu flux de treball iObtenir resultats consistents a través de les seves imatges.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object []

Els arguments .

Returns

ImageOptionsBase

Opcions de default

GetOriginalOptions()

Obtenir les opcions d’imatge original.

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Opcions d’imatge original.

GetUsedFonts()

Retirar la llista de fonts utilitzats en el metafísic amb aquest mètode.insights en l’ús de fonts, facilitant una gestió eficient i optimització del fontRecursos per a una millor renderització i mostrar fidelitat.

public override string[] GetUsedFonts()

Returns

string []

Llista de fonts

ResizeCanvas(Rectangle)

Recuperar els canvis amb facilitat utilitzant aquesta funció.Perfecte per ajustar el conjuntdimensions de la imatge sense alterar el seu contingut. millora la presentació iPreparar imatges per a diferents dimensions de pantalla sense esforç.

public override void ResizeCanvas(Rectangle newRectangle)

Parameters

newRectangle Rectangle

El nou rectangle.

SetPalette(Col·lecció, Bool)

Posa la paleta d’imatge.

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

La paleta s’ha de fixar.

updateColors bool

si s’estableix a “verd” colors es actualitzarà d’acord amb la nova paleta; en cas contrari, els índexs de color romandran inalterats.

Exceptions

NotImplementedException

 Català