←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#
C++/CLI
Java
Python
public bool ThrowExceptionsOnInvalidImages { get; set; } 
public boolean getThrowExceptionsOnInvalidImages() 
public void setThrowExceptionsOnInvalidImages(boolean value) 
             
public: 
property bool ThrowExceptionsOnInvalidImages { 
   bool get(); 
   void set (    bool ); 
} 
ThrowExceptionsOnInvalidImages # get and set (RasterCodecs) 

Property Value

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

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#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
public void ThrowExceptionsOnInvalidImagesExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // enable codec exceptions 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   try 
   { 
      RasterImage image = codecs.Load("some non-image file"); 
   } 
   catch 
   { 
      Debug.WriteLine("exception caught - sample sucess"); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
import java.io.*; 
import java.net.*; 
import java.nio.file.Paths; 
import java.util.*; 
import java.time.Instant; 
import java.time.Duration; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.codecs.RasterCodecs.FeedCallbackThunk; 
import leadtools.drawing.internal.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.color.ChangeIntensityCommand; 
import leadtools.svg.*; 
 
 
public void throwExceptionsOnInvalidImagesExample() { 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // enable codec exceptions 
   codecs.setThrowExceptionsOnInvalidImages(true); 
   try { 
      codecs.load("some non-image file"); 
   } catch (Exception e) { 
      System.out.println("exception caught - sample sucess"); 
   } 
 
   // Clean up 
   codecs.dispose(); 
} 
Requirements

Target Platforms

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

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.