В этом разделе
            
            Содержит статические свойства и методы, которые позволяют получить список доступных декодеров и найти декодер для изображения, хранящегося в файле или потоке.
            
            
Объектная модель
Синтаксис
            
            
            
            'Declaration
Public MustInherit NotInheritable Class AvailableDecoders
 
            
            public static class AvailableDecoders
 
            
            public __gc abstract __sealed class AvailableDecoders
 
            
            public ref class AvailableDecoders abstract sealed
 
	 
	
         
Пример
Вот пример, показывающий, как создать декодер и получить информацию о страницах изображения, хранящихся в указанном потоке:
    
	
	    
	    
''' <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();
    }
}
	     
	 
 
 
Иерархия наследования
System.Object
   Vintasoft.Imaging.Codecs.Decoders.AvailableDecoders
 
Требования
Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
 
Смотрите также