Class EmfImage

Class EmfImage

ชื่อพื้นที่: Aspose.Imaging.FileFormats.Emf การประกอบ: Aspose.Imaging.dll (25.4.0)

API for Enhanced Metafile Format (EMF) Vector Image Format สนับสนุนเครื่องมือที่ครอบคลุมสําหรับการประมวลผลภาพกราฟิกในอุปกรณ์ที่เป็นอิสระวิธีในขณะที่รักษาคุณสมบัติเดิมของพวกเขา พัฒนาเพื่อรักษาproportions, dimensions, colors, และคุณสมบัติกราฟิกอื่น ๆ มันรวมถึงการสนับสนุนรูปแบบและคุณสมบัติของ EMF Plus สําหรับภูมิภาคการเพาะปลูกการรีไซเคิลและภาพ, การหมุน, flipping, การตั้งค่าภาพแพลตฟอร์ม, การส่งออกและนําเข้าแบริ่งอุปกรณ์ 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 จากไฟล์และแปลงเป็น SVG โดยใช้ 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()

เริ่มต้นทํางานกับภาพ EMF โดยเริ่มต้นตัวอย่างใหม่ของคลาส Aspose.Imaging.FileFormats.Emf.EmfImage เหมาะสําหรับการรวมภาพ EMF ได้อย่างรวดเร็วโครงการของคุณได้อย่างง่ายดายและมีประสิทธิภาพ

[JsonConstructor]
public EmfImage()

EmfImage(int, int)

สร้างตัวอย่างใหม่ของคลาส Aspose.Imaging.FileFormats.Emf.EmfImage โดยระบุความกว้างและความสูงพารามิเตอร์ ผู้ก่อสร้างนี้ทําให้กระบวนการเริ่มต้นง่ายขึ้นรูปภาพ EMF ที่มีขนาดที่เฉพาะเจาะจงเพิ่มประสิทธิภาพการพัฒนาของคุณกระแสการทํางาน

public EmfImage(int width, int height)

Parameters

width int

ความกว้าง

height int

ความสูง

Properties

BitsPerPixel

ปรับคํานวณ bit-per-pixel โดยเฉพาะอย่างยิ่งสําหรับภาพ raster เนื่องจาก parameter นี้ไม่เกี่ยวข้องกับภาพ vector. ตรวจสอบความลึก pixel ของ raster ได้อย่างรวดเร็วภาพสําหรับการวิเคราะห์และการจัดการที่แม่นยําเพื่อให้แน่ใจว่าการจัดการที่ถูกต้องข้อมูลภาพ

public override int BitsPerPixel { get; }

คุณสมบัติมูลค่า

int

Exceptions

NotImplementedException

Invalid สําหรับภาพ vector

FileFormat

เข้าถึงค่ารูปแบบไฟล์ที่เกี่ยวข้องกับวัตถุได้อย่างง่ายดายระบุรูปแบบของไฟล์ที่เกี่ยวข้องกับวัตถุสําหรับการประมวลผลที่เรียบง่ายและตรวจสอบความเข้ากันได้ การซับซ้อนการทํางานของคุณโดยการรับรูปแบบไฟล์ข้อมูลได้ง่าย

public override FileFormat FileFormat { get; }

คุณสมบัติมูลค่า

FileFormat

Header

รับหรือปรับเปลี่ยนบันทึกหัวโลหะ EMF ด้วยคุณสมบัตินี้ เหมาะสําหรับการจัดการข้อมูลโลหะได้อย่างมีประสิทธิภาพภายในแอพลิเคชันของคุณ ปรับปรุงการทํางานของคุณด้วยการเข้าถึงข้อมูลหัวโลหะที่เรียบง่าย

public EmfMetafileHeader Header { get; set; }

คุณสมบัติมูลค่า

EmfMetafileHeader

ความสูง

ปรับปรุงความสูงของภาพช่วยให้การปรับการจัดเรียงและการจัดเรียงที่ถูกต้องการเข้าถึงคุณสมบัติความสูงช่วยให้การเข้ากันได้และการรวมกันอย่างต่อเนื่องแพลตฟอร์มและแอพพลิเคชันต่างๆ

public override float HeightF { get; }

คุณสมบัติมูลค่า

float

IsCached

การเข้าถึงค่าที่แสดงให้เห็นว่าข้อมูลของวัตถุในขณะนี้ถูกซ่อนอยู่หรือไม่การกําจัดความต้องการในการอ่านข้อมูลเพิ่มเติม เพิ่มประสิทธิภาพโดยเร็วตรวจสอบว่าข้อมูล cached มีการเข้าถึงทันที ปรับปรุงข้อมูลของคุณกระแสการทํางานด้วยกระบวนการรับข้อมูลที่ซับซ้อน

public override bool IsCached { get; }

คุณสมบัติมูลค่า

bool

Records

แก้ไขหรือแก้ไขบันทึกที่เกี่ยวข้องกับวัตถุ การเข้าถึงและการจัดการการเก็บข้อมูลเพื่อการจัดการและประมวลผลข้อมูลที่เพิ่มขึ้นปรับปรุงการทํางานของคุณโดยการโต้ตอบอย่างราบรื่นกับบันทึกของวัตถุ

public override MetaObjectList Records { get; set; }

คุณสมบัติมูลค่า

MetaObjectList

วีดีโอ

การเข้าถึงความกว้างของภาพให้ข้อมูลที่สําคัญเพื่อความแม่นยําการประมวลผลและการประมวลผล รับความกว้างของภาพได้อย่างรวดเร็วเพื่อให้แน่ใจว่ามีการเข้ากันได้และจัดตั้งที่เหมาะสมภายในแอพและแพลตฟอร์มต่างๆ

public override float WidthF { get; }

คุณสมบัติมูลค่า

float

Methods

CacheData()

การ cache ข้อมูลได้อย่างมีประสิทธิภาพและป้องกันการโหลดลดลงจากพื้นฐาน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

ImageOptionsBase

ตัวเลือกที่กําหนดเอง

GetOriginalOptions()

รับตัวเลือกภาพเดิม

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

ตัวเลือกภาพเดิม

GetUsedFonts()

ปรับปรุงรายการ fonts ที่ใช้ภายใน metaphile ด้วยวิธีการนี้ความเข้าใจเกี่ยวกับการใช้ font, ช่วยให้การจัดการที่มีประสิทธิภาพและการเพิ่มประสิทธิภาพของ fontวัตถุประสงค์ในการปรับปรุงการแสดงผลและการแสดงความซื่อสัตย์

public override string[] GetUsedFonts()

Returns

string [ ]

รายการ font

ResizeCanvas(Rectangle)

รีไซเคิลถังได้อย่างง่ายดายโดยใช้ฟังก์ชั่นนี้ เหมาะสําหรับการปรับตัวโดยรวมขนาดของภาพโดยไม่มีการเปลี่ยนแปลงเนื้อหาของภาพ การปรับปรุงการนําเสนอและการเตรียมภาพสําหรับขนาดจอแสดงผลที่แตกต่างกันอย่างหนัก

public override void ResizeCanvas(Rectangle newRectangle)

Parameters

newRectangle Rectangle

ตุ๊กตาใหม่

SetPalette(IColorPalette, บอล)

สร้างภาพแพลตฟอร์ม

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

แพลิเคชันที่กําหนดไว้

updateColors bool

หากกําหนดสี “จริง” จะได้รับการปรับปรุงตามแพลตฟอร์มใหม่; ในทางอื่น ๆ ตัวชี้วัดสีจะยังคงไม่เปลี่ยนแปลง. โปรดทราบว่าตัวชี้วัดที่ไม่ได้เปลี่ยนแปลงอาจรบกวนภาพบนโหลดถ้าบางตัวชี้วัดไม่มีรายการแพลตฟอร์มที่เกี่ยวข้อง.

Exceptions

NotImplementedException

 แบบไทย