LEADTOOLS Image File Support (Leadtools.Codecs assembly)
LEAD Technologies, Inc

LoadStatus Property

Example 





Gets a value that allows the detection of whether the image was loaded with errors. .NET support WinRT support Silverlight support
Syntax
public RasterExceptionCode LoadStatus {get;}
'Declaration
 
Public ReadOnly Property LoadStatus As RasterExceptionCode
'Usage
 
Dim instance As RasterCodecs
Dim value As RasterExceptionCode
 
value = instance.LoadStatus
public RasterExceptionCode LoadStatus {get;}
 get_LoadStatus(); 
public:
property RasterExceptionCode LoadStatus {
   RasterExceptionCode get();
}

Property Value

A Leadtools.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(String), LoadAsync(String,LeadRect,Int32,CodecsLoadByteOrder,Int32,Int32,Object) and FeedLoad(Byte[],Int32,Int32).

Example
 
Private Sub LoadStatusExample(ByVal fileName As String)
   Dim codecs As RasterCodecs = New RasterCodecs()
   Try
      Dim image As RasterImage = codecs.Load(fileName, 0, CodecsLoadByteOrder.Bgr, 1, 1)
      Dim loadStatusCode As RasterExceptionCode = codecs.LoadStatus
      If loadStatusCode = RasterExceptionCode.Success Then
         Console.WriteLine("The image was loaded successfully and with no errors")
      Else
         Console.WriteLine("The image was loaded, but it might have corrupted areas, error = {0}", loadStatusCode)
      End If

      image.Dispose()
   Catch ex As RasterException
      Console.WriteLine("LEADTOOLS could not load this image, error code is is '{0}', message is '{1}'", ex.Code, ex.Message)
   End Try

   ' Clean up
   codecs.Dispose()
End Sub
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)
            Console.WriteLine("The image was loaded successfully and with no errors");
        else
            Console.WriteLine("The image was loaded, but it might have corrupted areas, error = {0}", loadStatusCode);

        image.Dispose();
    }
    catch (RasterException ex)
    {
        Console.WriteLine("LEADTOOLS could not load this image, error code is is '{0}', message is '{1}'", ex.Code, ex.Message);
    }

    // Clean up
    codecs.Dispose();
}
RasterCodecsExamples.prototype.LoadStatusExample = function () {
   Tools.SetLicense();
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var fileName = "Assets\\BadExif.jpg";
         var codecs = new RasterCodecs();

         return Tools.AppInstallFolder().getFileAsync(fileName).then(function (loadFile) {
            return codecs.loadAsync(LeadStreamFactory.create(loadFile), 0, CodecsLoadByteOrder.bgr, 1, 1)
         })
            .then(function (image) {
               var loadStatusCode = codecs.loadStatus;
               if (loadStatusCode == RasterExceptionCode.success)
                  console.info("The image was loaded successfully and with no errors");
               else
                  console.info("The image was loaded, but it might have corrupted areas, error = {0}", loadStatusCode);

               image.close();

               // Clean up
               codecs.close();
            });
      }
   }
}
async Task LoadStatusExample(string fileName)
{
   RasterCodecs codecs = new RasterCodecs();
   try
   {
      StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(fileName);
      RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 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 (Exception ex)
   {
      string error = "";
      RasterException rasterException = RasterException.FromHResult(ex.HResult);
      if (rasterException != null)
         error = rasterException.Message;
      else
         error = ex.Message;
      Debug.WriteLine(error);
      Assert.Fail(error);
   }

   // Clean up
   codecs.Dispose();
}
void LoadStatusExample(Stream inStreamCorrupted)
{
   RasterCodecs codecs = new RasterCodecs();
   try
   {
      RasterImage image = codecs.Load(inStreamCorrupted, 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);
   }
}
Private Sub LoadStatusExample(ByVal inStreamCorrupted As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   Try
      Dim image As RasterImage = codecs.Load(inStreamCorrupted, 0, CodecsLoadByteOrder.Bgr, 1, 1)
      Dim loadStatusCode As RasterExceptionCode = codecs.LoadStatus
      If loadStatusCode = RasterExceptionCode.Success Then
         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)
      End If

      image.Dispose()
   Catch ex As RasterException
      Debug.WriteLine("LEADTOOLS could not load this image, error code is is '{0}', message is '{1}'", ex.Code, ex.Message)
   End Try
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterCodecs Class
RasterCodecs Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.