Class WmfImage

Class WmfImage

Tên không gian: Aspose.Imaging.FileFormats.Wmf Tổng hợp: Aspose.Imaging.dll (25.4.0)

Điều khiển hình ảnh Microsoft Windows Metafile (WMF) với API của chúng tôixử lý cả dữ liệu vector và bitmap được lưu trữ trong hồ sơ chiều dài biến.Tạo lại, xoay lại và nhấp vào hình ảnh một cách dễ dàng trong khi thiết lập bảng hình tùy chỉnh.Chuyển đổi các tệp WMF sang định dạng WmZ bị nén hoặc lưu chúng thành định hình hình rastercho việc sử dụng đa dạng trên các nền tảng và ứng dụng.

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

Inheritance

object DisposableObject DataStreamSupporter Image VectorImage MetaImage WmfImage

Implements

IDisposable , IObjectWithBounds , IObjectWithSizeF

Thành viên thừa kế

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

Ví dụ sau đây cho thấy làm thế nào để chuyển đổi một hình ảnh wmz sang từ từ 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});
                                                                                }

Ví dụ sau đây cho thấy làm thế nào để chuyển đổi một hình ảnh wmf sang từat

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});
                                                                                }

Ví dụ sau đây cho thấy làm thế nào để chuyển đổi một hình ảnh nén (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});
                                                                                                                    }
                                                                                                                }

Ví dụ này cho thấy làm thế nào để tải một hình ảnh WMF từ một tệp và chuyển đổi nó sang SVG bằng cách sử dụng WmfRasterizationOptions.

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

Tạo một ví dụ mới của lớp Aspose.Imaging.FileFormats.Wmf.MfImage, khởi động nó chotiếp tục thao tác và xử lý dữ liệu hình ảnh của Windows Metafile (WMF).nhà xây dựng cung cấp một đối tượng cơ bản để làm việc với hình ảnh WMF, cho phéptích hợp không dây các khả năng xử lý hình ảnh WMF vào ứng dụng của bạnchức năng

[JsonConstructor]
public WmfImage()

WmfImage(int, int)

Khởi động một trường hợp mới của lớp Aspose.Imaging.FileFormats.Wmf.MfImage với tùy chỉnhthông số chiều rộng và chiều cao, giúp tạo ra hình ảnh WMF trắngtùy chỉnh cho các kích thước cụ thể. Sử dụng máy xây dựng này để tạo ra năng độngHình ảnh WMF với kích thước chính xác, cho phép tạo hình ảnh linh hoạt vàthao túng trong ứng dụng của bạn.

public WmfImage(int width, int height)

Parameters

width int

Chiều rộng .

height int

Độ cao .

Properties

BitsPerPixel

Giảm số bit mỗi pixel cho hình ảnh, chỉ ra mức độ màuđộ sâu hoặc độ granularity. Sử dụng tài sản này để xác định màu sắc của hình ảnhđại diện và độ chính xác, tạo điều kiện kiểm tra sự tương thích và liên quan đến màu sắcxử lý trong ứng dụng của bạn.

[JsonIgnore]
public override int BitsPerPixel { get; }

Giá trị bất động sản

int

Exceptions

NotImplementedException

FileFormat

Truy cập giá trị định dạng tệp liên quan đến hình ảnh, cung cấp thông tinvề định dạng trong đó hình ảnh được lưu trữ. Sử dụng tài sản này để xác địnhđịnh dạng tệp của hình ảnh, tạo điều kiện để kiểm tra sự tương thích vàxử lý định dạng cụ thể trong ứng dụng của bạn.

public override FileFormat FileFormat { get; }

Giá trị bất động sản

FileFormat

FrameBounds

Truy cập các ranh giới của khung, chỉ ra vị trí và kích thước của nó trongSử dụng tài sản này để thu thập thông tin chi tiết về khungvị trí không gian, cho phép thao tác chính xác và rendering trong ứng dụng của bạn.

public Rectangle FrameBounds { get; }

Giá trị bất động sản

Rectangle

cao F

Truy cập độ cao của hình ảnh, đại diện cho số lượng pixel dọc theo chiều caoaxis. Sử dụng tài sản này để xác định kích thước không gian và khía cạnh của hình ảnhtỷ lệ, cho phép bố trí chính xác và thực hiện các điều chỉnh trong ứng dụng của bạn.

public override float HeightF { get; }

Giá trị bất động sản

float

Exceptions

NotImplementedException

Inch

Truy cập hoặc sửa đổi thuộc tính inch, đại diện cho một đơn vị đo thườngđược sử dụng để xác định các kích thước vật lý trong bối cảnh in hoặc hiển thị.tài sản để thiết lập hoặc thu thập giá trị inch liên quan đến hình ảnh,tạo điều kiện cho việc trình bày chính xác các kích thước vật lý trong ứng dụng của bạn.

public int Inch { get; set; }

Giá trị bất động sản

int

IsCached

Khôi phục một giá trị boolean cho thấy liệu dữ liệu của đối tượng hiện đang được ẩn,loại bỏ sự cần thiết cho các hoạt động đọc dữ liệu bổ sung. Sử dụng tài sản nàyđể tối ưu hóa hiệu suất bằng cách xác định liệu dữ liệu của đối tượng có sẵn hay khôngkhông cần phải có quá trình thu thập dữ liệu đắt tiền trong ứng dụng của bạn.

public override bool IsCached { get; }

Giá trị bất động sản

bool

Exceptions

NotImplementedException

Viên WidthF

Truy cập chiều rộng của hình ảnh, chỉ ra số lượng pixel dọc theoAxis horizontal. Sử dụng tài sản này để xác định kích thước không gian của hình ảnhvà tỷ lệ khía cạnh, cho phép bố trí chính xác và thực hiện các điều chỉnh trongứng dụng .

public override float WidthF { get; }

Giá trị bất động sản

float

Exceptions

NotImplementedException

Methods

AddRecord(WmfObject)

Nhúng mục ghi được chỉ định vào hình ảnh, làm giàu nội dung của nó vớithêm dữ liệu hoặc metadata. Sử dụng phương pháp này để tích hợp các bản ghicác đối tượng vào hình ảnh, tạo điều kiện cho việc lưu trữ dữ liệu toàn diện và tổ chứctrong ứng dụng của bạn.

public int AddRecord(WmfObject record)

Parameters

record WmfObject

kỷ lục .

Returns

int

Số kỷ lục

CacheData()

Cache dữ liệu một cách hiệu quả, loại bỏ nhu cầu tải thêm từdưới đây Aspose.Imaging.DataStreamSupporter.Thuyết minh.Hãy sử dụng điều nàyphương pháp để tối ưu hóa hiệu suất và giảm thiểu sử dụng tài nguyên trong ứng dụng của bạnbằng cách lưu trữ và truy cập dữ liệu cache địa phương.

public override void CacheData()

Examples

Ví dụ này cho thấy cách tải một hình ảnh WMF từ một tệp và liệt kê tất cả các bản ghi của nó.

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(đối tượng[])

Khôi phục các tùy chọn mặc định liên quan đến hình ảnh, cung cấp quyền truy cập vàocài đặt hoặc cấu hình được xác định trước. Sử dụng phương pháp này để truy cập mặc địnhcài đặt cho các hoạt động xử lý hình ảnh, tạo điều kiện nhất quán và thuận tiệntrong chức năng của ứng dụng của bạn.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object [ ]

Các Arguments .

Returns

ImageOptionsBase

Lựa chọn mặc định

GetOriginalOptions()

Nhận các tùy chọn hình ảnh ban đầu.

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Các tùy chọn hình ảnh ban đầu.

GetPostScript()

Truy cập dữ liệu PostScript liên quan đến hình ảnh, cung cấp chi tiếtthông tin về cấu trúc hoặc nội dung của nó. Sử dụng phương pháp này để thu thậpDữ liệu PostScript để phân tích hoặc xử lý thêm trong ứng dụng của bạn,cho phép chức năng tiên tiến liên quan đến PostScript rendering hoặc manipulation.

public string GetPostScript()

Returns

string

Post script bài viết

GetUsedFonts()

Đặt lại danh sách các phông chữ được sử dụng trong metaphile, cung cấp một cái nhìn sâu sắc vềfont resources used in the image. Sử dụng phương pháp này để phân tích việc sử dụng fontvà đảm bảo tính sẵn có của phông để trình bày hoặc xử lý thêm trong ứng dụng của bạn.

public override string[] GetUsedFonts()

Returns

string [ ]

Danh sách font

ResizeCanvas(Rectangle)

Khôi phục lại các đường ống của hình ảnh, điều chỉnh kích thước của nó trong khi duy trì ảnhSử dụng phương pháp này để thay đổi kích cỡ của bút chì mà không thay thếnội dung, tạo điều chỉnh bố trí và thay đổi thành phần trongứng dụng .

public override void ResizeCanvas(Rectangle newRectangle)

Parameters

newRectangle Rectangle

Mục đích mới.

Exceptions

NotImplementedException

SetPalette(Màn hình, bool)

Ứng dụng một bảng cụ thể vào hình ảnh, cho phép tùy chỉnh màu sắcSử dụng phương pháp này để cải thiện rendering thị giác vàhiệu ứng màu cụ thể trong ứng dụng của bạn.

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

Palette để đặt.

updateColors bool

nếu thiết lập màu sắc ’thực tế’ sẽ được cập nhật theo bảng mới; nếu không, chỉ số màu vẫn không thay đổi. Lưu ý rằng chỉ thị chưa thay thế có thể phá vỡ hình ảnh trên tải nếu một số chỉ mục có các mục bảng không tương ứng.

Exceptions

NotImplementedException

 Tiếng Việt