Class DisposableObject

Class DisposableObject

Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)

แทนวัตถุที่สามารถทิ้งได้

public class DisposableObject : IDisposable

การสืบทอด

objectDisposableObject

ที่สืบทอดมา

Brush, CdrObject, CmxContainer, CmxPage, DataStreamSupporter, EmbeddedImage, ImageOptionsBase, MaskingResult, StreamContainer, StringFormat

การใช้งาน

IDisposable

สมาชิกที่สืบทอดมา

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

คอนสตรัคเตอร์

DisposableObject()

public DisposableObject()

คุณสมบัติ

Disposed

รับค่าที่บ่งชี้ว่าสิ่งนี้ถูกทิ้งหรือไม่

public bool Disposed { get; }

ค่าของคุณสมบัติ

bool

วิธีการ

Dispose()

ทิ้งอินสแตนซ์ปัจจุบัน

public void Dispose()

ตัวอย่าง

ตัวอย่างต่อไปนี้แสดงวิธีการสร้าง TIFF หลายหน้าจากภาพเรสเตอร์แต่ละภาพ```csharp [C#]

                                                                                                 Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
                                                                                                 createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\multipage.tif", false);
                                                                                                 createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
                                                                                                 createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };

                                                                                                 using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
                                                                                                 {
                                                                                                     // นี่คือฟอนต์และแปรงสำหรับวาดข้อความบนเฟรมแต่ละเฟรม
                                                                                                     Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
                                                                                                     Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);

                                                                                                     // สร้าง 5 เฟรม
                                                                                                     for (int i = 1; i <= 5; i++)
                                                                                                     {
                                                                                                         Aspose.Imaging.ImageOptions.PngOptions createPngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                         createPngOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());

                                                                                                         // สร้างภาพ PNG และวาดหมายเลขหน้าลงไป
                                                                                                         Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Create(createPngOptions, 100, 100);
                                                                                                         Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);
                                                                                                         gr.DrawString(i.ToString(), font, brush, 10, 10);

                                                                                                         // สร้างเฟรมตามภาพ PNG
                                                                                                         Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);

                                                                                                         // เพิ่มเฟรมไปยังภาพ TIFF
                                                                                                         tiffImage.AddFrame(frame);
                                                                                                     }

                                                                                                     // ภาพถูกสร้างขึ้นด้วยเฟรมเริ่มต้นเพียงเฟรมเดียว ให้ลบมันออก
                                                                                                     Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
                                                                                                     tiffImage.ActiveFrame = tiffImage.Frames[1];
                                                                                                     tiffImage.RemoveFrame(0);

                                                                                                     // อย่าลืมทิ้งเฟรมหากคุณไม่ต้องการเพิ่มมันไปยัง TiffImage อื่น
                                                                                                     activeFrame.Dispose();

                                                                                                     tiffImage.Save();
                                                                                                 }

### <a id="Aspose_Imaging_DisposableObject_Finalize"></a> \~DisposableObject\(\)

```csharp
protected ~DisposableObject()

ReleaseManagedResources()

ปล่อยทรัพยากรที่จัดการแล้ว ตรวจสอบว่าไม่มีทรัพยากรที่ไม่ได้จัดการถูกปล่อยที่นี่ เนื่องจากอาจถูกปล่อยแล้ว

protected virtual void ReleaseManagedResources()

ReleaseUnmanagedResources()

ปล่อยทรัพยากรที่ไม่ได้จัดการ ตรวจสอบว่าไม่มีทรัพยากรที่จัดการแล้วถูกปล่อยที่นี่ เนื่องจากอาจถูกปล่อยแล้ว

protected virtual void ReleaseUnmanagedResources()

VerifyNotDisposed()

ตรวจสอบว่าอินสแตนซ์ปัจจุบันไม่ได้ถูกทิ้ง

protected void VerifyNotDisposed()
 แบบไทย