VintaSoft Imaging .NET SDK 15.2: Документация для .NET разработчика
Vintasoft.Imaging.Codecs.Decoders Namespace / IRasterGridDecoder Interface
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
IRasterGridDecoder Интерфейс
В этом разделе
Определяет интерфейс для растрового декодера, который может использовать сетку изображения с масштабированием для декодирования изображения.
Объектаня модель
IRasterGridDecoder
Синтаксис
'Declaration

Public Interface IRasterGridDecoder

public interface IRasterGridDecoder

Пример

Вот пример, показывающий, как получить левую верхнюю область JPEG2000 изображения, уменьшенную в 4 раза:


''' <summary>
''' Returns a 4 times downscaled image of left-top rectangle of JPEG2000 image.
''' </summary>
Public Shared Function GetJpeg2000RectangleDownscaled4(filename As String) As Vintasoft.Imaging.VintasoftImage
    Using stream As System.IO.Stream = New System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
        Using decoder As New Vintasoft.Imaging.Codecs.Decoders.Jpeg2000Decoder(stream)
            ' check available scales
            Dim scales As Integer() = decoder.GetImageRectScales(0, decoder.GetDefaultDecodingSettings(0))
            For i As Integer = 0 To scales.Length - 1
                If scales(i) = 4 Then
                    ' get top-left rectangle of raster grid with scale 4
                    Return decoder.GetImageRect(0, 0, 4, Nothing, Nothing, Nothing)
                End If
            Next

            Throw New System.Exception("Scale 4 is not available for specified JPEG2000 file.")
        End Using
    End Using
End Function


/// <summary>
/// Returns a 4 times downscaled image of left-top rectangle of JPEG2000 image.
/// </summary>
public static Vintasoft.Imaging.VintasoftImage GetJpeg2000RectangleDownscaled4(string filename)
{
    using (System.IO.Stream stream =
        new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
    {
        using (Vintasoft.Imaging.Codecs.Decoders.Jpeg2000Decoder decoder =
            new Vintasoft.Imaging.Codecs.Decoders.Jpeg2000Decoder(stream))
        {
            // check available scales
            int[] scales = decoder.GetImageRectScales(0, decoder.GetDefaultDecodingSettings(0));
            for (int i = 0; i < scales.Length; i++)
            {
                if (scales[i] == 4)
                {
                    // get top-left rectangle of raster grid with scale 4
                    return decoder.GetImageRect(0, 0, 4, null, null, null);
                }
            }

            throw new System.Exception("Scale 4 is not available for specified JPEG2000 file.");
        }
    }
}

Требования

Целевые платформы: .NET 11; .NET 10; .NET 9; .NET 8; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

Смотрите также