Class EmfImage

Class EmfImage

Il nome: Aspose.Imaging.FileFormats.Emf Assemblea: Aspose.Imaging.dll (25.4.0)

Il supporto API per il formato Metafile Enhanced (EMF) vector image format èuno strumento completo per il trattamento delle immagini grafiche in un dispositivo indipendenteper la conservazione delle loro proprietà originali. sviluppato per mantenereproporzioni, dimensioni, colori e altri attributi grafici, comprendeEMF Plus formato supporto e funzionalità per le regioni di raccolta, canvas di rigenerazionee immagini, rotating, flipping, impostazione delle palette di immagine, esportazione e importazioneper il contesto del dispositivo APS, la compressione e la conversione di EMF in altri formati, assicurandoLa manipolazione versatile e l’integrazione senza precedenti delle immagini EMF attraverso le applicazioni.

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

Inheritance

object DisposableObject DataStreamSupporter Image VectorImage MetaImage EmfImage

Implements

IDisposable , IObjectWithBounds , IObjectWithSizeF

I membri ereditari

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’esempio seguente mostra come convertire un’immagine emz in 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’esempio seguente mostra come convertire una immagine emf in 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});
                                                                                }

Il seguente esempio mostra come convertire un’immagine compressa (di EMZ,.wmz, *.svgz) per 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});
                                                                                                                    }
                                                                                                                }

Questo esempio mostra come caricare un’immagine EMF da un file e converterla in SVG utilizzando 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()

Inizia a lavorare con le immagini EMF iniziando una nuova instanza delAspose.Imaging.FileFormats.Emf. EmfImage classe. ideale per incorporare rapidamente le immagini EMF inI vostri progetti con facilità ed efficienza.

[JsonConstructor]
public EmfImage()

EmfImage(di int, int)

Creare una nuova instanza della classe Aspose.Imaging.FileFormats.Emf. EmfImage specificando la larghezzae parametri di altezza. questo costruttore semplifica il processo di inizializzazioneImmagini EMF con dimensioni specifiche, migliorando l’efficienza del tuo sviluppoIl flusso di lavoro.

public EmfImage(int width, int height)

Parameters

width int

La larghezza .

height int

La altezza .

Properties

BitsPerPixel

Retrate il conteggio bit-per-pixel specifico per le immagini di raster, in quanto questo parametronon si applica alle immagini vectori. rapidamente rilevare la profondità del pixel del rasterImmagini per analisi e manipolazioni accurate, assicurando un trattamento accuratodei dati di immagine.

public override int BitsPerPixel { get; }

Valore di proprietà

int

Exceptions

NotImplementedException

Invalidità per le immagini vectoriali.

FileFormat

Accedere al valore del formato del file associato all’oggetto.il formato del file associato all’oggetto per il trattamento strutturato eControlli di compatibilità. semplificare il flusso di lavoro recuperando il formato del fileInformazioni con facilità.

public override FileFormat FileFormat { get; }

Valore di proprietà

FileFormat

Header

Ristrutturare o modificare il record del titolo metafilico EMF con questa proprietà.Gestire i metafili in modo efficiente all’interno della tua applicazione. Migliorare il tuo flusso di lavorocon accesso semplificato alle informazioni del titolo metafilico.

public EmfMetafileHeader Header { get; set; }

Valore di proprietà

EmfMetafileHeader

AltezzaF

Retrate l’altezza dell’immagine, facilitando adeguamenti di rendering e layout accurati.L’accesso alla proprietà di altezza assicura la compatibilità e l’integrazione senza sfiore traPiattaforme e applicazioni diverse.

public override float HeightF { get; }

Valore di proprietà

float

IsCached

accedere a un valore che indica se i dati dell’oggetto sono attualmente cache,eliminare la necessità di ulteriori lettura dei dati. migliorare l’efficienza con rapiditàdeterminare se i dati cache sono disponibili per l’accesso immediato.Il flusso di lavoro con processi di recupero dei dati semplificati.

public override bool IsCached { get; }

Valore di proprietà

bool

Records

Ripristinare o modificare i record associati all’oggetto.gestire la raccolta dei record per il miglioramento della manipolazione e del trattamento dei dati.Ottimizzare il flusso di lavoro interagendo senza sforzo con i record dell’oggetto.

public override MetaObjectList Records { get; set; }

Valore di proprietà

MetaObjectList

di WidthF

L’accesso alla larghezza dell’immagine, fornendo informazioni essenziali per la precisionerendering e elaborazione. rapida recupera la larghezza dell’immagine per garantire la compatibilitàe il corretto layout all’interno di varie applicazioni e piattaforme.

public override float WidthF { get; }

Valore di proprietà

float

Methods

CacheData()

Cache i dati in modo efficiente e prevenire il carico redundante dal sottostanteAspose.Imaging.DataStreamSupporter.data StreamContainer con questo metodo.Efficienza e efficienza dell’accesso ai dati nella tua applicazione, ottimizzazione delle risorseutilizzo per migliorare la risposta.

public override void CacheData()

Examples

Questo esempio mostra come caricare un’immagine EMF da un file e elencare tutti i suoi record.

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

Retrate le opzioni predefinite per la vostra immagine senza sforzo.Possono accedere rapidamente alle configurazioni pre-set, assicurando l’integrazione senza segni erendimento ottimale per i tuoi progetti. ideale per semplificare il tuo flusso di lavoro eottenere risultati coerenti attraverso le tue immagini.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object [ ]

Gli argomenti .

Returns

ImageOptionsBase

Opzioni di default

GetOriginalOptions()

Ottieni le opzioni di immagine originali.

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Le opzioni immagine originali.

GetUsedFonts()

Ripristinare l’elenco delle font utilizzate all’interno della metafisica con questo metodo.insegnamenti sull’utilizzo delle fonti, facilitando la gestione efficiente e l’ottimizzazione delle fontRisorse per migliorare il rendering e la fedeltà della visualizzazione.

public override string[] GetUsedFonts()

Returns

string [ ]

L’elenco dei font

ResizeCanvas(Rectangle)

Ristrutturare con facilità le canve utilizzando questa funzione. Perfetto per adattare l’interodimensioni dell’immagine senza modificare il suo contenuto. migliorare la presentazione ePreparare le immagini per le varie dimensioni dello schermo senza sforzo.

public override void ResizeCanvas(Rectangle newRectangle)

Parameters

newRectangle Rectangle

Il nuovo rettangolo.

SetPalette(IcolorPalette, Bool)

Inserisci la paletta dell’immagine.

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

La paletta da impostare.

updateColors bool

se impostati a colori ‘giuri’ verrà aggiornato in base alla nuova paletta; altrimenti gli indici di colore rimangono invariati. Nota che gli indici invariati possono crollare l’immagine sul carico se alcuni indici non hanno entrate di paletta corrispondenti.

Exceptions

NotImplementedException

 Italiano