Class PngLoadOptions

Class PngLoadOptions

Namespace: Aspose.Imaging.ImageLoadOptions
Assembly: Aspose.Imaging.dll (25.4.0)

The png load options.

[Obsolete("Should be replaced with base \"LoadOptions\" class because it contains ony one obsolete \"StrictMode\" property.")]
public class PngLoadOptions : LoadOptions

Inheritance

objectLoadOptionsPngLoadOptions

Inherited Members

LoadOptions.AddCustomFontSource(CustomFontSource, params object[]), LoadOptions.DataRecoveryMode, LoadOptions.DataBackgroundColor, LoadOptions.UseIccProfileConversion, LoadOptions.BufferSizeHint, LoadOptions.ProgressEventHandler, LoadOptions.ConcurrentImageProcessing, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

PngLoadOptions()

public PngLoadOptions()

Properties

StrictMode

Gets or sets a value indicating whether [strict mode].

[Obsolete("This redundant property should be replaced with an expression: \"LoadOptions.DataRecoveryMode == DataRecoveryMode.ConsistentRecover\".")]
public bool StrictMode { get; set; }

Property Value

bool

Examples

The following example shows how to read PNG file in a strict mode. The strict mode allows to find potential problems in PNG images, e.g. unrecognized data blocks, unexpected end of file. Such files still can be opened in default (non-strict) mode by Aspose.Imaging and by common viewers as well. However any attempts to open them in the strict mode cause a corresponding exception.

string dir = "c:\\aspose.imaging\\issues\\net\\3635\\testdata\\3565";
                                                                                                                                                                                                                                                                                                                                                                                                        string inputFileName = System.IO.Path.Combine(dir, "FC5F1998104EB92469CB14070628073616BB28F9.png");
                                                                                                                                                                                                                                                                                                                                                                                                        string outputFileName = inputFileName + ".png";

                                                                                                                                                                                                                                                                                                                                                                                                        // Default mode (non-strict) - successul reading.
                                                                                                                                                                                                                                                                                                                                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFileName))
                                                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                                                            image.Save(outputFileName, new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                                                                                                                        // Strict mode - ImageLoadException : Unexpected end of file.
                                                                                                                                                                                                                                                                                                                                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFileName, new Aspose.Imaging.ImageLoadOptions.PngLoadOptions() { StrictMode = true }))
                                                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                                                            image.Save(outputFileName, new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                                                                                                                                                                                                                                                        }