Class DataStreamSupporter

Class DataStreamSupporter

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

dữ liệu lưu trữ container.

[JsonObject(MemberSerialization.OptIn)]
public abstract class DataStreamSupporter : DisposableObject, IDisposable

Inheritance

object DisposableObject DataStreamSupporter

Derived

Image

Implements

IDisposable

Thành viên thừa kế

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

Constructors

DataStreamSupporter()

Bắt đầu một trường hợp mới của lớp Aspose.Imaging.DataStreamSupporter.

[JsonConstructor]
protected DataStreamSupporter()

Fields

Thời gian

Thời gian chờ đợi cho đồng bộ hóa

[JsonProperty]
protected int timeout

Giá trị Field

int

Properties

DataStreamContainer

Nhận dòng dữ liệu của đối tượng.

public StreamContainer DataStreamContainer { get; }

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

StreamContainer

IsCached

Nó nhận được một giá trị cho thấy liệu dữ liệu của đối tượng hiện đang được ẩn và không cần đọc dữ liệu.

public abstract bool IsCached { get; }

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

bool

Methods

CacheData()

Cache dữ liệu và đảm bảo rằng không có thêm tải data sẽ được thực hiện từ Aspose.Imaging.DataStreamSupporter.

public abstract void CacheData()

Examples

Ví dụ sau đây cho thấy làm thế nào caching hình ảnh ảnh hưởng đến hiệu suất.Trong trường hợp nói chung, việc đọc dữ liệu cache được thực hiện nhanh hơn so với việc tìm hiểu không cach data.

string dir = "c:\\temp\\";

                                                                                                                                                                    // Load an image from a PNG file.
                                                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                                    {
                                                                                                                                                                        // Cache all pixel data so that no additional data loading will be performed from the underlying data stream
                                                                                                                                                                        image.CacheData();

                                                                                                                                                                        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                                                                                                                                                                        stopwatch.Start();

                                                                                                                                                                        // Reading all pixels is pretty fast.
                                                                                                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
                                                                                                                                                                        for (int y = 0; y < image.Height; y++)
                                                                                                                                                                        {
                                                                                                                                                                            for (int x = 0; x < image.Width; x++)
                                                                                                                                                                            {
                                                                                                                                                                                int color = rasterImage.GetArgb32Pixel(x, y);
                                                                                                                                                                            }
                                                                                                                                                                        }

                                                                                                                                                                        stopwatch.Stop();
                                                                                                                                                                        System.Console.WriteLine("Reading all cached pixels took {0} ms.", stopwatch.ElapsedMilliseconds);
                                                                                                                                                                    }

                                                                                                                                                                    // Load an image from a PNG file
                                                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                                    {
                                                                                                                                                                        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                                                                                                                                                                        stopwatch.Start();

                                                                                                                                                                        // Reading all pixels is not as fast as when caching
                                                                                                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
                                                                                                                                                                        for (int y = 0; y < image.Height; y++)
                                                                                                                                                                        {
                                                                                                                                                                            for (int x = 0; x < image.Width; x++)
                                                                                                                                                                            {
                                                                                                                                                                                int color = rasterImage.GetArgb32Pixel(x, y);
                                                                                                                                                                            }
                                                                                                                                                                        }

                                                                                                                                                                        stopwatch.Stop();
                                                                                                                                                                        System.Console.WriteLine("Reading all pixels without preliminary caching took {0} ms.", stopwatch.ElapsedMilliseconds);
                                                                                                                                                                    }

                                                                                                                                                                    // The output may look like this:
                                                                                                                                                                    // Reading all cached pixels took 1500 ms.
                                                                                                                                                                    // Reading all pixels without preliminary caching took 150000 ms.

OnDataStreamContainerChanging(StreamContainer)

Được gọi khi container dữ liệu lưu lượng đang thay đổi.

protected virtual void OnDataStreamContainerChanging(StreamContainer streamContainer)

Parameters

streamContainer StreamContainer

Vòng container dòng.

ReleaseManagedResources()

Hãy chắc chắn rằng không có tài nguyên không được quản lý được phát hành ở đây, vì chúng có thể đã được phát hành.

protected override void ReleaseManagedResources()

Save()

Lưu dữ liệu của đối tượng vào Aspose.Imaging.DataStreamSupporter hiện tại.

public virtual void Save()

Save(Stream)

Lưu dữ liệu của đối tượng vào dòng cụ thể.

public void Save(Stream stream)

Parameters

stream Stream

dòng để lưu dữ liệu của đối tượng đến.

Save(String)

Lưu dữ liệu của đối tượng đến vị trí tệp cụ thể.

public virtual void Save(string filePath)

Parameters

filePath string

Hướng dẫn file để lưu dữ liệu của đối tượng đến.

Save(Lời bài hát: Bool)

Lưu dữ liệu của đối tượng đến vị trí tệp cụ thể.

public virtual void Save(string filePath, bool overWrite)

Parameters

filePath string

Hướng dẫn file để lưu dữ liệu của đối tượng đến.

overWrite bool

Nếu bạn đặt vào ’true’ trên viết nội dung tệp, nếu không thêm sẽ xảy ra.

SaveData(Stream)

Tiết kiệm dữ liệu

protected abstract void SaveData(Stream stream)

Parameters

stream Stream

Stream để lưu dữ liệu đến.

 Tiếng Việt