VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Codecs.Decoders Namespace / AvailableDecoders Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    AvailableDecoders Class
    In This Topic
    Contains static properties and methods that allow to get a list of available decoders and find decoder for the image stored in file or stream.
    Object Model
    AvailableDecoders
    Syntax
    'Declaration
    
    Public MustInherit NotInheritable Class AvailableDecoders
    
    
    public static class AvailableDecoders
    
    
    public __gc abstract __sealed class AvailableDecoders
    
    
    public ref class AvailableDecoders abstract sealed
    
    
    Example

    Here is an example that shows how to create a decoder and get information about pages of image stored in the specified stream:

    
    ''' <summary>
    ''' Shows detailed information about pages of image stored in specified stream.
    ''' </summary>
    Public Shared Sub ShowInformationAboutPages(stream As System.IO.Stream)
        Dim decoder As Vintasoft.Imaging.Codecs.Decoders.DecoderBase
        Try
            ' create appropriate decoder
            decoder = Vintasoft.Imaging.Codecs.Decoders.AvailableDecoders.CreateDecoder(stream)
        Catch ex As Vintasoft.Imaging.Codecs.Decoders.DecoderException
            System.Console.WriteLine(ex.Message)
            Return
        End Try
    
        If decoder Is Nothing Then
            System.Console.WriteLine("Appropriate decoder was not found.")
            Return
        End If
    
        ' get the number of pages
        System.Console.WriteLine(String.Format("Stream contains {0} page(s).", decoder.PageCount))
        For i As Integer = 0 To decoder.PageCount - 1
            ' get the information about the page
            Dim pageImageInfo As Vintasoft.Imaging.Codecs.Decoders.ImageInfo = decoder.GetImageInfo(i)
    
            System.Console.WriteLine()
    
            ' get general image parameters
    
            System.Console.WriteLine(String.Format("Page {0}:", i + 1))
            System.Console.WriteLine(String.Format("  Image dimensions: {0}x{1} pixels", pageImageInfo.Width, pageImageInfo.Height))
            System.Console.WriteLine(String.Format("  Image resolution: {0}x{1} dpi", System.Math.Round(pageImageInfo.Resolution.Horizontal), System.Math.Round(pageImageInfo.Resolution.Vertical)))
            System.Console.WriteLine(String.Format("  Image bit depth: {0}", pageImageInfo.BitsPerPixel))
            System.Console.WriteLine(String.Format("  Image pixel format: {0}", pageImageInfo.PixelFormat))
    
            ' get information about palette
    
            Dim paletteColorCount As Integer = pageImageInfo.Palette.ColorCount
            If paletteColorCount > 0 Then
                System.Console.WriteLine(String.Format("  Image has a palette with {0} colors", paletteColorCount))
            Else
                System.Console.WriteLine(String.Format("  Image has no palette"))
            End If
            System.Console.WriteLine()
        Next
    End Sub
    
    
    
    /// <summary>
    /// Shows detailed information about pages of image stored in specified stream.
    /// </summary>
    public static void ShowInformationAboutPages(System.IO.Stream stream)
    {
        Vintasoft.Imaging.Codecs.Decoders.DecoderBase decoder;
        try
        {
            // create appropriate decoder
            decoder = Vintasoft.Imaging.Codecs.Decoders.AvailableDecoders.CreateDecoder(stream);
        }
        catch (Vintasoft.Imaging.Codecs.Decoders.DecoderException ex)
        {
            System.Console.WriteLine(ex.Message);
            return;
        }
    
        if (decoder == null)
        {
            System.Console.WriteLine("Appropriate decoder was not found.");
            return;
        }
    
        // get the number of pages
        System.Console.WriteLine(string.Format("Stream contains {0} page(s).", decoder.PageCount));
        for (int i = 0; i < decoder.PageCount; i++)
        {
            // get the information about the page
            Vintasoft.Imaging.Codecs.Decoders.ImageInfo pageImageInfo = decoder.GetImageInfo(i);
    
            System.Console.WriteLine();
    
            // get general image parameters
    
            System.Console.WriteLine(string.Format("Page {0}:", i + 1));
            System.Console.WriteLine(string.Format("  Image dimensions: {0}x{1} pixels", pageImageInfo.Width, pageImageInfo.Height));
            System.Console.WriteLine(string.Format("  Image resolution: {0}x{1} dpi",
                System.Math.Round(pageImageInfo.Resolution.Horizontal), System.Math.Round(pageImageInfo.Resolution.Vertical)));
            System.Console.WriteLine(string.Format("  Image bit depth: {0}", pageImageInfo.BitsPerPixel));
            System.Console.WriteLine(string.Format("  Image pixel format: {0}", pageImageInfo.PixelFormat));
    
            // get information about palette
    
            int paletteColorCount = pageImageInfo.Palette.ColorCount;
            if (paletteColorCount > 0)
                System.Console.WriteLine(string.Format("  Image has a palette with {0} colors", paletteColorCount));
            else
                System.Console.WriteLine(string.Format("  Image has no palette"));
            System.Console.WriteLine();
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Codecs.Decoders.AvailableDecoders

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also