Class DisposableObject
Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)
Đại diện cho đối tượng có thể hủy.
public class DisposableObject : IDisposable
Kế thừa
Kế thừa
Brush, CdrObject, CmxContainer, CmxPage, DataStreamSupporter, EmbeddedImage, ImageOptionsBase, MaskingResult, StreamContainer, StringFormat
Triển khai
Các thành viên được kế thừa
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Các hàm khởi tạo
DisposableObject()
public DisposableObject()
Thuộc tính
Disposed
Lấy giá trị cho biết liệu thể hiện này đã bị hủy hay chưa.
public bool Disposed { get; }
Giá trị thuộc tính
Các phương thức
Dispose()
Hủy thể hiện hiện tại.
public void Dispose()
Ví dụ
Ví dụ sau đây cho thấy cách tạo một TIFF đa trang từ các hình ảnh raster riêng lẻ.```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))
{
// Đây là Font và Brush để vẽ văn bản trên các khung riêng lẻ.
Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);
// Tạo 5 khung
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());
// Tạo một hình ảnh PNG và vẽ số trang trên đó.
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);
// Tạo một khung dựa trên hình ảnh PNG.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);
// Thêm khung vào hình ảnh TIFF.
tiffImage.AddFrame(frame);
}
// Hình ảnh đã được tạo với một khung mặc định duy nhất. Hãy xóa nó.
Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
tiffImage.ActiveFrame = tiffImage.Frames[1];
tiffImage.RemoveFrame(0);
// Đừng quên hủy khung nếu bạn không thêm nó vào một TiffImage khác
activeFrame.Dispose();
tiffImage.Save();
}
### <a id="Aspose_Imaging_DisposableObject_Finalize"></a> \~DisposableObject\(\)
```csharp
protected ~DisposableObject()
ReleaseManagedResources()
Giải phóng các tài nguyên được quản lý. Đảm bảo không có tài nguyên không được quản lý nào được giải phóng ở đây, vì chúng có thể đã được giải phóng.
protected virtual void ReleaseManagedResources()
ReleaseUnmanagedResources()
Giải phóng các tài nguyên không được quản lý. Đảm bảo không có tài nguyên được quản lý nào được giải phóng ở đây, vì chúng có thể đã được giải phóng.
protected virtual void ReleaseUnmanagedResources()
VerifyNotDisposed()
Xác minh rằng thể hiện hiện tại chưa bị hủy.
protected void VerifyNotDisposed()