←Select platform

LoadStatus Property

Summary
Gets a value that allows detection of whether the image was loaded with errors.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterExceptionCode LoadStatus { get; } 
@property (nonatomic, assign, readonly) LTError loadStatus 
public RasterExceptionCode getLoadStatus() 
public: 
property RasterExceptionCode LoadStatus { 
   RasterExceptionCode get(); 
} 
LoadStatus # get  (RasterCodecs) 

Property Value

A RasterExceptionCode which indicates the result of the most recent load operation.

The most common return values are:

Value Meaning
RasterExceptionCode.Success The image loaded by the last load call does not have any errors.
RasterExceptionCode.CompressedDataFailure There were errors decoding the last image. The bottom part of the image might be corrupted.
RasterExceptionCode.BadResyncMarker Some of the resync markers were incorrect or missing while decoding the last image. Resync markers are used by JPEG files to recover from decoding errors. Portions of the image are corrupted. They are indicated by a checkerboard pattern.
RasterExceptionCode.FileRead The file was truncated. The bottom part of the image is missing.
Remarks

An error return code is a warning that portions of the image that was last loaded might be corrupted.

This property should be called after a load method has been successfully called. This value is reset after each page is loaded, so if you are loading multiple pages, this error code is valid only for the last page.

If the last load method threw an exception, then this method should not be used, as its return value is undefined.

Note that this property is valid for the current thread. So it should be used in the same thread as the load method.

This is valid for all the methods that will load an image, including Load, LoadAsync or LoadSvg and FeedLoad.

Example

This example will load an image and check whether the image has corrupted areas.

C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
void LoadStatusExample(string fileName) 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   try 
   { 
      RasterImage image = codecs.Load(fileName, 0, CodecsLoadByteOrder.Bgr, 1, 1); 
      RasterExceptionCode loadStatusCode = codecs.LoadStatus; 
      if (loadStatusCode == RasterExceptionCode.Success) 
         Debug.WriteLine("The image was loaded successfully and with no errors"); 
      else 
         Debug.WriteLine("The image was loaded, but it might have corrupted areas, error = {0}", loadStatusCode); 
 
      image.Dispose(); 
   } 
   catch (RasterException ex) 
   { 
      Debug.WriteLine("LEADTOOLS could not load this image, error code is is '{0}', message is '{1}'", ex.Code, ex.Message); 
   } 
 
   // 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 loadStatusExample() { 
   String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String fileName = combine(LEAD_VARS_IMAGES_DIR, "cannon.jpg"); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   try { 
      RasterImage image = codecs.load(fileName, 0, CodecsLoadByteOrder.BGR, 1, 1); 
      RasterExceptionCode loadStatusCode = codecs.getLoadStatus(); 
      if (loadStatusCode == RasterExceptionCode.SUCCESS) 
         System.out.println("The image was loaded successfully and with no errors"); 
      else 
         System.out.printf("The image was loaded, but it might have corrupted areas, error = %s", loadStatusCode); 
 
      image.dispose(); 
   } catch (RasterException ex) { 
      System.out.printf( 
            "LEADTOOLS could not load this image, error code is is '%s', message is '%s'", 
            ex.getCode(), 
            ex.getMessage()); 
   } 
 
   // 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.