A value indicating whether to throw an exception instead of returning a null reference on certain methods of this RasterCodecs object.
public bool ThrowExceptionsOnInvalidImages { get; set; } Public Property ThrowExceptionsOnInvalidImages As Boolean public boolean getThrowExceptionsOnInvalidImages()public void setThrowExceptionsOnInvalidImages(boolean value)
A value indicating whether to throw an exception instead of returning a null reference on certain methods of this RasterCodecs object.
Some of the methods of this RasterCodecs class will return an object when called. For example, the Load or LoadAsync methods will return the RasterImage object created. If the value of ThrowExceptionsOnInvalidImages is set to true, then the Load or LoadAsync methods return a null reference instead when it encounters an error and cannot return a valid image.
The following methods will either throw an exception or return a null reference depending on the setting of the ThrowExceptionsOnInvalidImages property.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;using LeadtoolsExamples.Common;public void ThrowExceptionsOnInvalidImagesExample(){RasterCodecs codecs = new RasterCodecs();// enable codec exceptionscodecs.ThrowExceptionsOnInvalidImages = true;try{RasterImage image = codecs.Load("some non-image file");}catch{Console.WriteLine("exception caught - sample sucess");}// Clean upcodecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingImports Leadtools.SvgPublic Sub ThrowExceptionsOnInvalidImagesExample()Dim codecs As RasterCodecs = New RasterCodecs()' enable codec exceptionscodecs.ThrowExceptionsOnInvalidImages = TrueTryDim image As RasterImage = codecs.Load("some non-image file")CatchConsole.WriteLine("exception caught - sample sucess")End Try' Clean upcodecs.Dispose()End Sub
c#[Silverlight C# Example]using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Windows.Media;public void ThrowExceptionsOnInvalidImagesExample(Stream inStream){RasterCodecs codecs = new RasterCodecs();// enable codec exceptionscodecs.ThrowExceptionsOnInvalidImages = true;try{RasterImage image = codecs.Load(inStream); //some non-image file}catch{Debug.WriteLine("exception caught - sample sucess");}}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.MediaPublic Sub ThrowExceptionsOnInvalidImagesExample(ByVal inStream As Stream)Dim codecs As RasterCodecs = New RasterCodecs()' enable codec exceptionscodecs.ThrowExceptionsOnInvalidImages = TrueTryDim image As RasterImage = codecs.Load(inStream) 'some non-image fileCatchDebug.WriteLine("exception caught - sample sucess")End TryEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
