Loading...
Searching...
No Matches
NCBitmapRegionDecoder Class Reference

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

#include <com/navigine/idl/objc/NCBitmapRegionDecoder.h>

Inherits NSObject.

Instance Methods

(nullable UIImage *) - decodeRegion:sampleSize:
 Method is used to decode rectangle region in the image specified by rect.
 

Class Methods

(nullable NCBitmapRegionDecoder *) + newInstance:
 Method is used to create instance of BitmapRegionDecoder.
 
(nullable NCBitmapRegionDecoder *) + newInstanceFromImage:
 Creates decoder from Image without copying raw bytes again.
 

Properties

int32_t width
 Width of the source image in pixels (after header parse / decode metadata).
 
int32_t 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 19 of file NCBitmapRegionDecoder.h.

Method Documentation

◆ decodeRegion:sampleSize:

- (nullable UIImage *) decodeRegion: (nonnull NCRectangle *) rect
sampleSize: (float) 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

Swift code snippet:

// Decode region with sample size 1 (full resolution)
let decodedImage = decoder.decodeRegion(rect: sampleRect, sampleSize: 1)
print("Decoded region: \‍(sampleRect.width)x\‍(sampleRect.height) at sample size 1")

Objective C code snippet:

// Decode region with sample size 1 (full resolution)
id decodedImage = [self.decoder decodeRegionWithRect:sampleRect sampleSize:1];
NSLog(@"Decoded region: %dx%d at sample size 1", sampleRect.width, sampleRect.height);

◆ newInstance:

+ (nullable NCBitmapRegionDecoder *) newInstance: (nonnull NSData *) data

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.

Swift code snippet:

// Create new instance of BitmapRegionDecoder
decoder = BitmapRegionDecoder.newInstance(data: imageData)
print("Created BitmapRegionDecoder instance")

Objective C code snippet:

// Create new instance of BitmapRegionDecoder
self.decoder = [NCBitmapRegionDecoder newInstanceWithData:self.imageData];
NSLog(@"Created BitmapRegionDecoder instance");

◆ newInstanceFromImage:

+ (nullable NCBitmapRegionDecoder *) newInstanceFromImage: (nullable NCImage *) data

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

Swift code snippet:

// When you already have an Image (e.g. from SDK), create decoder without passing raw bytes again
let imageForDecoder: Image? = nil // set from your pipeline when available
let decoderFromImage = BitmapRegionDecoder.newInstanceFromImage(data: imageForDecoder)
print("Decoder from Image: \‍(decoderFromImage != nil)")

Objective C code snippet:

// When you already have an Image (e.g. from SDK), create decoder without passing raw bytes again
NCImage *imageForDecoder = nil; // set from your pipeline when available
NCBitmapRegionDecoder *decoderFromImage = [NCBitmapRegionDecoder newInstanceFromImageWithData:imageForDecoder];
NSLog(@"Decoder from Image: %@", decoderFromImage != nil ? @"yes" : @"no");

Property Documentation

◆ height

- (int32_t) height
readnonatomicassign

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

Swift code snippet:

let sourceHeight = decoder!.height
print("Source image height: \‍(sourceHeight)")

Objective C code snippet:

int32_t sourceHeight = self.decoder.height;
NSLog(@"Source image height: %d", sourceHeight);

Definition at line 102 of file NCBitmapRegionDecoder.h.

◆ width

- (int32_t) width
readnonatomicassign

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

Swift code snippet:

let sourceWidth = decoder!.width
print("Source image width: \‍(sourceWidth)")

Objective C code snippet:

int32_t sourceWidth = self.decoder.width;
NSLog(@"Source image width: %d", sourceWidth);

Definition at line 87 of file NCBitmapRegionDecoder.h.


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