←Select platform

ThrowExceptionsOnInvalidImages Property

Summary

A value indicating whether to throw an exception instead of returning a null reference on certain methods of this RasterCodecs object.

Syntax
C#
VB
Java
C++
public bool ThrowExceptionsOnInvalidImages { get; set; } 
Public Property ThrowExceptionsOnInvalidImages As Boolean 
public boolean getThrowExceptionsOnInvalidImages() 
public void setThrowExceptionsOnInvalidImages(boolean value) 
             
public: 
property bool ThrowExceptionsOnInvalidImages { 
   bool get(); 
   void set (    bool ); 
} 

Property Value

A value indicating whether to throw an exception instead of returning a null reference on certain methods of this RasterCodecs object.

Remarks

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.

Example
C#
VB
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 exceptions 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   try 
   { 
      RasterImage image = codecs.Load("some non-image file"); 
   } 
   catch 
   { 
      Console.WriteLine("exception caught - sample sucess"); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
Imports Leadtools.Drawing 
Imports Leadtools.Svg 
 
Public Sub ThrowExceptionsOnInvalidImagesExample() 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   ' enable codec exceptions 
   codecs.ThrowExceptionsOnInvalidImages = True 
   Try 
      Dim image As RasterImage = codecs.Load("some non-image file") 
   Catch 
      Console.WriteLine("exception caught - sample sucess") 
   End Try 
 
   ' Clean up 
   codecs.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 exceptions 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   try 
   { 
      RasterImage image = codecs.Load(inStream); //some non-image file 
   } 
   catch 
   { 
      Debug.WriteLine("exception caught - sample sucess"); 
   } 
} 
vb[Silverlight VB Example] 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
Imports Leadtools.Windows.Media 
 
Public Sub ThrowExceptionsOnInvalidImagesExample(ByVal inStream As Stream) 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   ' enable codec exceptions 
   codecs.ThrowExceptionsOnInvalidImages = True 
   Try 
      Dim image As RasterImage = codecs.Load(inStream) 'some non-image file 
   Catch 
      Debug.WriteLine("exception caught - sample sucess") 
   End Try 
End Sub 

Requirements

Target Platforms

Help Version 20.0.2019.9.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly