VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.ImageRendering Namespace / ImageRenderingTask Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс ImageRenderingTask
    В этом разделе
    Задача на отрисовку области изображения с масштабированием. Доступно прогрессивное декодирование.
    Объектная модель
    VintasoftImage ImageRenderingTask
    Синтаксис
    'Declaration
    
    Public Class ImageRenderingTask
    
    
    public class ImageRenderingTask
    
    
    public __gc class ImageRenderingTask
    
    
    public ref class ImageRenderingTask
    
    
    Пример

    Вот C#/VB.NET код, который демонстрирует, как использовать рендерер изображений для: получения прямоугольника изображения или прогрессивной загрузки изображения Jpeg2000.

    
    Public Class ImageRenderingTaskExample
        ' Gets the specified rectangle of image in specified scale.
        Public Shared Function GetScaledImageRect(image As Vintasoft.Imaging.VintasoftImage, rect As System.Drawing.Rectangle, scale As Single) As Vintasoft.Imaging.VintasoftImage
            ' create image renderer
            Using renderer As New Vintasoft.Imaging.ImageRendering.ImageRenderer(image)
                ' create rendering task
                Dim task As Vintasoft.Imaging.ImageRendering.ImageRenderingTask = Vintasoft.Imaging.ImageRendering.ImageRenderingTask.CreateImageRegion(rect, scale)
                ' execute rendering
                Return renderer.ExecuteRendering(task)
            End Using
        End Function
    
        ' Gets an Jpeg2000 image using progressive decoding.
        Public Shared Function GetJpeg2000ImageUsingProgressiveLoading(jp2Filename As String) As Vintasoft.Imaging.VintasoftImage
            ' create image
            Using image As New Vintasoft.Imaging.VintasoftImage(jp2Filename)
                ' create image renderer
                Using renderer As New Vintasoft.Imaging.ImageRendering.ImageRenderer(image)
                    ' create rendering task
                    Dim task As Vintasoft.Imaging.ImageRendering.ImageRenderingTask = Vintasoft.Imaging.ImageRendering.ImageRenderingTask.CreateScaledImage(1)
    
                    ' set settings of rendering task
                    task.DestImagePixelFormat = Vintasoft.Imaging.PixelFormat.Bgra32
                    task.RenderingQuality = Vintasoft.Imaging.ImageRenderingQuality.High
                    task.NeedGenerateIntermediateImage = True
                    task.IsProgressiveDecodingEnabled = True
                    task.ProgressiveDecodingMode = Vintasoft.Imaging.ImageRendering.ProgressiveDecodingMode.Replacement
                    task.ProgressiveDecodingRenderingQuality = Vintasoft.Imaging.ImageRenderingQuality.High
                    task.ProgressiveDecodingDepth = 2
                    task.ProgressiveDecodingScaleFactor = 6
                    task.MaxThreads = 2
                    task.DecodingSteps = task.MaxThreads * 8
    
                    ' use IntermediateImageReady event: image part or progressive layer is loaded
                    AddHandler task.IntermediateImageReady, New System.EventHandler(Of Vintasoft.Imaging.ImageRendering.IntermediateImageReadyEventArgs)(AddressOf task_IntermediateImageReady)
    
                    ' execute rendering
                    Return renderer.ExecuteRendering(task)
                End Using
            End Using
        End Function
    
        ' Image part or progressive layer is loaded:
        ' show the e.ChangedRect rectangle of the e.Image on your viewer.
        Private Shared Sub task_IntermediateImageReady(sender As Object, e As Vintasoft.Imaging.ImageRendering.IntermediateImageReadyEventArgs)
            '...
        End Sub
    End Class
    
    
    
    public class ImageRenderingTaskExample
    {
        // Gets the specified rectangle of image in specified scale.
        public static Vintasoft.Imaging.VintasoftImage GetScaledImageRect(
            Vintasoft.Imaging.VintasoftImage image, System.Drawing.Rectangle rect, float scale)
        {
            // create image renderer
            using (Vintasoft.Imaging.ImageRendering.ImageRenderer renderer =
                new Vintasoft.Imaging.ImageRendering.ImageRenderer(image))
            {
                // create rendering task
                Vintasoft.Imaging.ImageRendering.ImageRenderingTask task =
                    Vintasoft.Imaging.ImageRendering.ImageRenderingTask.CreateImageRegion(rect, scale);
                // execute rendering
                return renderer.ExecuteRendering(task);
            }
        }
    
        // Gets an Jpeg2000 image using progressive decoding.
        public static Vintasoft.Imaging.VintasoftImage GetJpeg2000ImageUsingProgressiveLoading(string jp2Filename)
        {
            // create image
            using (Vintasoft.Imaging.VintasoftImage image = new Vintasoft.Imaging.VintasoftImage(jp2Filename))
            // create image renderer
            using (Vintasoft.Imaging.ImageRendering.ImageRenderer renderer =
                new Vintasoft.Imaging.ImageRendering.ImageRenderer(image))
            {
                // create rendering task
                Vintasoft.Imaging.ImageRendering.ImageRenderingTask task =
                    Vintasoft.Imaging.ImageRendering.ImageRenderingTask.CreateScaledImage(1);
    
                // set settings of rendering task
                task.DestImagePixelFormat = Vintasoft.Imaging.PixelFormat.Bgra32;
                task.RenderingQuality = Vintasoft.Imaging.ImageRenderingQuality.High;
                task.NeedGenerateIntermediateImage = true;
                task.IsProgressiveDecodingEnabled = true;
                task.ProgressiveDecodingMode = Vintasoft.Imaging.ImageRendering.ProgressiveDecodingMode.Replacement;
                task.ProgressiveDecodingRenderingQuality = Vintasoft.Imaging.ImageRenderingQuality.High;
                task.ProgressiveDecodingDepth = 2;
                task.ProgressiveDecodingScaleFactor = 6;
                task.MaxThreads = 2;
                task.DecodingSteps = task.MaxThreads * 8;
    
                // use IntermediateImageReady event: image part or progressive layer is loaded
                task.IntermediateImageReady +=
                    new System.EventHandler<Vintasoft.Imaging.ImageRendering.IntermediateImageReadyEventArgs>(task_IntermediateImageReady);
    
                // execute rendering
                return renderer.ExecuteRendering(task);
            }
        }
    
        // Image part or progressive layer is loaded:
        // show the e.ChangedRect rectangle of the e.Image on your viewer.
        private static void task_IntermediateImageReady(object sender, Vintasoft.Imaging.ImageRendering.IntermediateImageReadyEventArgs e)
        {
            //...
        }
    }
    
    

    Иерархия наследования

    System.Object
       Vintasoft.Imaging.ImageRendering.ImageRenderingTask

    Требования

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

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