GetTileImage(DecodingSettings,Int32,Int32,EventHandler<ProgressEventArgs>) Метод (Jpeg2000Page)
В этом разделе
Возвращает изображение указанного фрагмента этой страницы, декодированное с указанным количеством вейвлет-уровней.
Синтаксис
Parameters
- tileIndex
- Индекс плитки отсчитывается от нуля.
- decodingSettings
- Настройки декодирования, которые следует использовать для декодирования изображения страницы.
- waveletLevels
- Количество дискретных уровней вейвлет-преобразования (уровней разложения).
- imageLoadingProgress
- Делегирует ход загрузки изображения. Может быть установлено значение null (Nothing в Visual Basic).
Return Value
Масштабированное изображение, связанное с указанным тайлом.
Исключения
Ремарки
Плитка декодируется в немасштабированном виде, если waveletLevels равно WaveletLevels; в противном случае тайл декодируется с использованием масштаба (2 в степени (WaveletLevels - waveletLevels)).
Пример
Вот C#/VB.NET код, который демонстрирует, как открыть JPEG файл2000 и получить его изображение по частям.
' Opens JPEG2000 file and gets its image by parts.
Public Shared Function GetJpeg2000ImageByParts(jpeg2000Filename As String) As Vintasoft.Imaging.VintasoftImage
' open an existing JPEG2000 file
Using file As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
' get JPEG2000 page
Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page = file.Page
' get page dimensions and pixel format
Dim imageWidth As Integer = page.Width
Dim imageHeight As Integer = page.Height
Dim palette As Vintasoft.Imaging.Palette = If(page.Palette IsNot Nothing, page.Palette, New Vintasoft.Imaging.Palette())
Dim imageInfo As New Vintasoft.Imaging.Codecs.Decoders.ImageInfo(imageWidth, imageHeight, page.BitsPerPixel, palette, page.Resolution)
Dim pixelFormat As Vintasoft.Imaging.PixelFormat = imageInfo.PixelFormat
' get tiles grid of the page
Dim tilesGrid As System.Drawing.Rectangle() = page.GetTileGrid()
' get tiles count
Dim tileCount As Integer = tilesGrid.Length
' get number of wavelet levels
Dim waveletLevel As Integer = page.WaveletLevels
' create a VintasoftImage object
Dim resultImage As New Vintasoft.Imaging.VintasoftImage(imageWidth, imageHeight, pixelFormat)
' for each tile in page
For i As Integer = 0 To tileCount - 1
' get current rectangle
Dim tileRectangle As System.Drawing.Rectangle = tilesGrid(i)
' get current rectangle location
Dim position As System.Drawing.Point = tileRectangle.Location
' get image of current tile
Using tile As Vintasoft.Imaging.VintasoftImage = page.GetTileImage(i, waveletLevel, Nothing)
' overlay tile on result image
Dim overlayCommand As New Vintasoft.Imaging.ImageProcessing.OverlayCommand(tile, position)
overlayCommand.ExecuteInPlace(resultImage)
End Using
Next
Return resultImage
End Using
End Function
// Opens JPEG2000 file and gets its image by parts.
public static Vintasoft.Imaging.VintasoftImage GetJpeg2000ImageByParts(string jpeg2000Filename)
{
// open an existing JPEG2000 file
using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File file =
new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(
jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
// get JPEG2000 page
Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page page = file.Page;
// get page dimensions and pixel format
int imageWidth = page.Width;
int imageHeight = page.Height;
Vintasoft.Imaging.Palette palette = page.Palette != null ? page.Palette : new Vintasoft.Imaging.Palette();
Vintasoft.Imaging.Codecs.Decoders.ImageInfo imageInfo =
new Vintasoft.Imaging.Codecs.Decoders.ImageInfo(
imageWidth,
imageHeight,
page.BitsPerPixel,
palette,
page.Resolution);
Vintasoft.Imaging.PixelFormat pixelFormat = imageInfo.PixelFormat;
// get tiles grid of the page
System.Drawing.Rectangle[] tilesGrid = page.GetTileGrid();
// get tiles count
int tileCount = tilesGrid.Length;
// get number of wavelet levels
int waveletLevel = page.WaveletLevels;
// create a VintasoftImage object
Vintasoft.Imaging.VintasoftImage resultImage =
new Vintasoft.Imaging.VintasoftImage(imageWidth, imageHeight, pixelFormat);
// for each tile in page
for (int i = 0; i < tileCount; i++)
{
// get current rectangle
System.Drawing.Rectangle tileRectangle = tilesGrid[i];
// get current rectangle location
System.Drawing.Point position = tileRectangle.Location;
// get image of current tile
using (Vintasoft.Imaging.VintasoftImage tile = page.GetTileImage(i, waveletLevel, null))
{
// overlay tile on result image
Vintasoft.Imaging.ImageProcessing.OverlayCommand overlayCommand =
new Vintasoft.Imaging.ImageProcessing.OverlayCommand(tile, position);
overlayCommand.ExecuteInPlace(resultImage);
}
}
return resultImage;
}
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также