Loading...
Searching...
No Matches
BitmapRegionDecoder Class Referenceabstract

Class is used for getting bitmaps (png, jpg, svg) from byte array. More...

Inherits Finalizable.

Public Member Functions

ImageWrapper decodeRegion (Rectangle rect, double sampleSize)
 Method is used to decode rectangle region in the image specified by rect.
 

Static Public Member Functions

static BitmapRegionDecoder newInstance (Uint8List data)
 Method is used to create instance of BitmapRegionDecoder.
 
static BitmapRegionDecoder newInstanceFromImage (Image data)
 Creates decoder from Image without copying raw bytes again.
 

Public Attributes

int get width
 Width of the source image in pixels (after header parse / decode metadata).
 
int get height
 Height of the source image in pixels (after header parse / decode metadata).
 

Detailed Description

Class is used for getting bitmaps (png, jpg, svg) from byte array.

Definition at line 21 of file bitmap_region_decoder.dart.

Member Function Documentation

◆ decodeRegion()

ImageWrapper BitmapRegionDecoder.decodeRegion ( Rectangle rect,
double sampleSize )

Method is used to decode rectangle region in the image specified by rect.

Parameters
rectarea to render Rectangle
sampleSizeif set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory.
Returns
constructed bitmap

Dart code snippet:

// Decode region with sample size 1 (full resolution)
ImageWrapper decodedImage = _decoder!.decodeRegion(sampleRect, 1);
print(
"Decoded region: ${sampleRect.width}x${sampleRect.height} at sample size 1",
);

◆ newInstance()

static BitmapRegionDecoder BitmapRegionDecoder.newInstance ( Uint8List data)
static

Method is used to create instance of BitmapRegionDecoder.

Parameters
dataraw image data (could be raw svg string)
Returns
nstance of decoder, which could be used for decoding byte array to bitmap.

Dart code snippet:

// Create new instance of BitmapRegionDecoder
_decoder = BitmapRegionDecoder.newInstance(_imageData!);
print("Created BitmapRegionDecoder instance");

◆ newInstanceFromImage()

static BitmapRegionDecoder BitmapRegionDecoder.newInstanceFromImage ( Image data)
static

Creates decoder from Image without copying raw bytes again.

Parameters
dataimage instance (e.g. from SDK pipeline); must remain valid while decoder is used
Returns
decoder instance or null on error

Dart code snippet:

// When you already have an Image (e.g. from SDK), create decoder without passing raw bytes again
final Image? imageForDecoder = null; // set from your pipeline when available
final BitmapRegionDecoder? decoderFromImage =
BitmapRegionDecoder.newInstanceFromImage(imageForDecoder);
print('Decoder from Image: ${decoderFromImage != null}');

Member Data Documentation

◆ height

int get BitmapRegionDecoder.height

Height of the source image in pixels (after header parse / decode metadata).

Dart code snippet:

final sourceHeight = _decoder!.height;
print('Source image height: $sourceHeight');

Definition at line 87 of file bitmap_region_decoder.dart.

◆ width

int get BitmapRegionDecoder.width

Width of the source image in pixels (after header parse / decode metadata).

Dart code snippet:

final sourceWidth = _decoder!.width;
print('Source image width: $sourceWidth');

Definition at line 76 of file bitmap_region_decoder.dart.


The documentation for this class was generated from the following file: