Class WmfImage
ชื่อพื้นที่: Aspose.Imaging.FileFormats.Wmf การประกอบ: Aspose.Imaging.dll (25.4.0)
การจัดการภาพ Microsoft Windows Metafile (WMF) ด้วย API ของเราการจัดการข้อมูลทั้ง vector และ bitmap ที่เก็บไว้ภายในบันทึกความยาวที่เปลี่ยนแปลงการรีไซเคิลการหมุนและฟิลิปภาพได้อย่างง่ายดายในขณะที่ตั้งค่าแพลตฟอร์มภาพที่กําหนดเองแปลงไฟล์ WMF ไปยังรูปแบบ WMZ ที่บีบอัดหรือบันทึกไว้ในรูปแบบภาพสกรูสําหรับการใช้งานที่หลากหลายทั่วแพลตฟอร์มและแอพลิเคชัน
[JsonObject(MemberSerialization.OptIn)]
public class WmfImage : MetaImage, IDisposable, IObjectWithBounds, IObjectWithSizeF
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← VectorImage ← MetaImage ← WmfImage
Implements
IDisposable , IObjectWithBounds , IObjectWithSizeF
อนุญาโตตุลาการ
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
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการแปลงภาพ wmz ไปยังภาพ 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});
}
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการแปลงภาพ wmf ไปยัง wmz fromat
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});
}
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการแปลงภาพที่บีบอัด (.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});
}
}
ตัวอย่างนี้แสดงให้เห็นวิธีการโหลดภาพ WMF จากไฟล์และแปลงเป็น SVG โดยใช้ 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()
สร้างตัวอย่างใหม่ของคลาส Aspose.Imaging.FileFormats.Wmf.WmfImage เริ่มต้นสําหรับการจัดการเพิ่มเติมและการประมวลผลของข้อมูลภาพของ Windows Metafile (WMF)ผู้สร้างให้วัตถุพื้นฐานสําหรับการทํางานกับภาพ WMFการรวมความสามารถในการจัดการภาพ WMF ในแอปพลิเคชันของคุณการทํางาน
[JsonConstructor]
public WmfImage()
WmfImage(int, int)
Instant a new instance of the Aspose.Imaging.FileFormats.Wmf.WmfImage class with customizableความกว้างและความสูงพารามิเตอร์ทําให้การสร้างภาพ WMF สีขาวง่ายขึ้นที่กําหนดเองสําหรับขนาดที่เฉพาะเจาะจง ใช้เครื่องก่อสร้างนี้เพื่อสร้างแบบไดนามิกภาพ WMF ที่มีขนาดที่แม่นยําช่วยให้การสร้างภาพที่ยืดหยุ่นและการจัดการภายในแอพลิเคชันของคุณ
public WmfImage(int width, int height)
Parameters
width
int
ความกว้าง
height
int
ความสูง
Properties
BitsPerPixel
คัดลอกจํานวนบิตต่อพิกเซลสําหรับภาพแสดงให้เห็นถึงระดับสีความลึกหรือ granularity ใช้คุณสมบัตินี้เพื่อกําหนดสีของภาพการแสดงผลและความแม่นยําช่วยให้การตรวจสอบความเข้ากันได้และสีที่เกี่ยวข้องการประมวลผลภายในใบสมัครของคุณ
[JsonIgnore]
public override int BitsPerPixel { get; }
คุณสมบัติมูลค่า
Exceptions
FileFormat
เข้าถึงค่ารูปแบบไฟล์ที่เกี่ยวข้องกับภาพให้ข้อมูลเกี่ยวกับรูปแบบที่ภาพถูกเก็บไว้ ใช้คุณสมบัตินี้เพื่อระบุรูปแบบไฟล์ของภาพช่วยให้การตรวจสอบความเข้ากันได้และการประมวลผลแบบกําหนดเองภายในแอพลิเคชันของคุณ
public override FileFormat FileFormat { get; }
คุณสมบัติมูลค่า
FrameBounds
เข้าถึงขอบเขตของกรอบแสดงตําแหน่งและขนาดภายในภาพ. ใช้คุณสมบัตินี้เพื่อรับข้อมูลรายละเอียดเกี่ยวกับกรอบตําแหน่งพื้นที่ช่วยให้การจัดการและ rendering ที่แม่นยําภายในแอพลิเคชันของคุณ
public Rectangle FrameBounds { get; }
คุณสมบัติมูลค่า
ความสูง
เข้าถึงความสูงของภาพซึ่งแสดงให้เห็นถึงจํานวนพิกเซลตามแนวตั้งของภาพaxis. ใช้คุณสมบัตินี้เพื่อตรวจสอบขนาดพื้นที่และรูปร่างของภาพratio, ช่วยให้การจัดตั้งที่แม่นยําและให้การปรับภายในแอพของคุณ
public override float HeightF { get; }
คุณสมบัติมูลค่า
Exceptions
Inch
การเข้าถึงหรือเปลี่ยนคุณสมบัติ นิ้วซึ่งเป็นหน่วยวัดทั่วไปใช้ในการกําหนดขนาดทางกายภาพในรูปแบบการพิมพ์หรือการแสดงผล ใช้นี้คุณสมบัติในการตั้งค่าหรือรับค่า Inch ที่เกี่ยวข้องกับภาพช่วยให้การแสดงผลที่แม่นยําของขนาดทางกายภาพภายในแอพพลิเคชันของคุณ
public int Inch { get; set; }
คุณสมบัติมูลค่า
IsCached
รับค่า Boolean ที่แสดงให้เห็นว่าข้อมูลของวัตถุในขณะนี้ถูกซ่อนอยู่หรือไม่การกําจัดความต้องการสําหรับการดําเนินการอ่านข้อมูลเพิ่มเติม ใช้สินทรัพย์นี้เพื่อเพิ่มประสิทธิภาพโดยการตรวจสอบว่าข้อมูลของวัตถุที่มีอยู่ได้อย่างง่ายดายไม่จําเป็นต้องใช้กระบวนการรับข้อมูลที่มีค่าใช้จ่ายภายในใบสมัครของคุณ
public override bool IsCached { get; }
คุณสมบัติมูลค่า
Exceptions
วีดีโอ
การเข้าถึงความกว้างของภาพแสดงให้เห็นถึงจํานวนพิกเซลในระยะยาวมุมแนวนอน ใช้คุณสมบัตินี้เพื่อกําหนดขนาดพื้นที่ของภาพและความสัมพันธ์ด้านที่ช่วยให้การจัดระเบียบที่แม่นยําและการปรับตัวภายในของคุณการประยุกต์ใช้
public override float WidthF { get; }
คุณสมบัติมูลค่า
Exceptions
Methods
AddRecord(WmfObject)
ใส่วัตถุบันทึกที่ระบุลงในภาพทําให้เนื้อหาของมันอุดมไปด้วยข้อมูลเพิ่มเติมหรือข้อมูลโลหะ ใช้วิธีการนี้เพื่อบูรณาการบันทึกได้อย่างราบรื่นวัตถุในภาพช่วยให้การจัดเก็บข้อมูลและองค์กรที่ครอบคลุมภายในใบสมัครของคุณ
public int AddRecord(WmfObject record)
Parameters
record
WmfObject
บันทึก
Returns
จํานวนบันทึก
CacheData()
การเข้ารหัสข้อมูลได้อย่างมีประสิทธิภาพเพื่อกําจัดความต้องการในการโหลดเพิ่มเติมจากภายใต้ Aspose.Imaging.DataStreamSupporter.DataStreamContainer ใช้นี้วิธีการเพิ่มประสิทธิภาพและลดการใช้ทรัพยากรภายในแอพของคุณโดยการจัดเก็บและเข้าถึง cache ของข้อมูลในท้องถิ่น
public override void CacheData()
Examples
ตัวอย่างนี้แสดงให้เห็นวิธีการโหลดภาพ WMF จากไฟล์และรายการบันทึกทั้งหมด
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
GetDefaultOptions(วัตถุ[])
ลบตัวเลือกเริ่มต้นที่เกี่ยวข้องกับภาพให้การเข้าถึงการตั้งค่าหรือการตั้งค่าที่กําหนดเอง ใช้วิธีการนี้เพื่อเข้าถึงการตั้งค่าที่กําหนดเองการตั้งค่าสําหรับการดําเนินการการประมวลผลภาพช่วยให้ความสม่ําเสมอและความสะดวกสบายภายในฟังก์ชั่นของแอพของคุณ
public override ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[ ]
ข้อตกลง
Returns
ตัวเลือกที่กําหนดเอง
GetOriginalOptions()
รับตัวเลือกภาพเดิม
public override ImageOptionsBase GetOriginalOptions()
Returns
ตัวเลือกภาพเดิม
GetPostScript()
เข้าถึงข้อมูล PostScript ที่เกี่ยวข้องกับภาพให้รายละเอียดข้อมูลเกี่ยวกับโครงสร้างหรือเนื้อหาของมัน ใช้วิธีการนี้เพื่อรับข้อมูล PostScript สําหรับการวิเคราะห์เพิ่มเติมหรือการประมวลผลภายในแอพของคุณให้คุณสมบัติขั้นสูงที่เกี่ยวข้องกับ PostScript rendering หรือ manipulation
public string GetPostScript()
Returns
โพสต์สคริปต์
GetUsedFonts()
รับรายชื่อข้อความที่ใช้ภายในเมทาฟิลเพื่อให้เห็นถึงทรัพยากร font ที่ใช้ในภาพ ใช้วิธีการนี้เพื่อวิเคราะห์การใช้ fontและให้แน่ใจว่ามีอักษรสําหรับการส่งมอบหรือการประมวลผลเพิ่มเติมภายในแอพลิเคชันของคุณ
public override string[] GetUsedFonts()
Returns
string [ ]
รายการ font
ResizeCanvas(Rectangle)
รีไซเคิลช่องของภาพปรับขนาดของภาพในขณะที่รักษาภาพเนื้อหา ใช้วิธีการนี้เพื่อปรับขนาดของถังโดยไม่ต้องเปลี่ยนขนาดของถังเนื้อหาที่ช่วยให้การปรับการจัดตั้งและการเปลี่ยนแปลงการประกอบภายในของคุณการประยุกต์ใช้
public override void ResizeCanvas(Rectangle newRectangle)
Parameters
newRectangle
Rectangle
ตุ๊กตาใหม่
Exceptions
SetPalette(IColorPalette, บอล)
ใช้แพลตฟอร์มที่กําหนดไว้สําหรับภาพเพื่อให้สามารถปรับแต่งสีได้การแสดงผล ใช้วิธีการนี้เพื่อปรับปรุงการแสดงผลภาพและรายงานผลสีที่เฉพาะเจาะจงภายในแอพลิเคชันของคุณ
public override void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
แพลิเคชันที่กําหนดไว้
updateColors
bool
หากกําหนดไว้เป็นสี “จริง” จะได้รับการปรับปรุงตามแพลตฟอร์มใหม่; ในทางอื่น ๆ ตัวชี้วัดสีจะยังคงไม่เปลี่ยนแปลง. โปรดทราบว่าตัวชี้วัดที่ไม่ได้เปลี่ยนแปลงอาจรบกวนภาพบนโหลดหากบางตัวชี้วัดมีรายการแพลตฟอร์มที่ไม่สอดคล้อง