NTBitmap


@interface NTBitmap : NSObject {
  void *swigCPtr;
  BOOL swigCMemOwn;
}

A class that provides the functionality to store, compress, uncompress and resize basic image formats. Currently supported formats are png and jpeg. Upon loading compressed images will be converted to alpha premultiplied uncompressed bitmaps of various image formats.

  • Checks if this object is equal to the specified object.

    Declaration

    Objective-C

    - (BOOL)isEqual:(id)object;

    Parameters

    object

    The reference object.

    Return Value

    True when objects are equal, false otherwise.

  • Returns the hash value of this object.

    Declaration

    Objective-C

    - (NSUInteger)hash;

    Return Value

    The hash value of this object.

  • Constructs a bitmap from an already decoded vector of bytes. The bitmap data is expected to be alpha premultiplied, if alpha channel is used. If the power of two conversion flag is set, additional padding will be added to the image to make it’s dimensions power of two. This can be useful when creating OpenGL textures from the Bitmap, because some GPUs perform badly with non power of two textures.

    Declaration

    Objective-C

    - (id)initWithPixelData:(NTBinaryData *)pixelData
                      width:(unsigned int)width
                     height:(unsigned int)height
                colorFormat:(enum NTColorFormat)colorFormat
                bytesPerRow:(int)bytesPerRow;

    Parameters

    pixelData

    A vector of decoded, premultiplied bitmap bytes.

    width

    The width of the bitmap.

    height

    The height of the bitmap.

    colorFormat

    The color format of the bitmap.

    bytesPerRow

    The total number of bytes per row. Some bitmaps have additional padding at the end of each row. If the value is negative, then bitmap is assumed to be vertically flipped. In this case absolute value of the bytesPerRow value is used.

  • Returns the width of the bitmap.

    Declaration

    Objective-C

    - (unsigned int)getWidth;

    Return Value

    The width of the bitmap.

  • Returns the height of the bitmap.

    Declaration

    Objective-C

    - (unsigned int)getHeight;

    Return Value

    The height of the bitmap.

  • Returns the color format of this bitmap.

    Declaration

    Objective-C

    - (enum NTColorFormat)getColorFormat;

    Return Value

    The color format of this bitmap.

  • Returns the bytes per pixel parameter of this bitmap. Valid values are 1, 2, 3 and 4.

    Declaration

    Objective-C

    - (unsigned int)getBytesPerPixel;

    Return Value

    The bytes per pixel parameter of this bitmap.

  • Returns a copy of the pixel data of this bitmap.

    Declaration

    Objective-C

    - (NTBinaryData *)getPixelData;

    Return Value

    A binary data of the bitmap’s pixel data.

  • Compresses this bitmap to a PNG format.

    Declaration

    Objective-C

    - (NTBinaryData *)compressToPNG;

    Return Value

    A byte vector of the PNG’s data.

  • Compresses this bitmap to a internal format. This operation is intended for serialization of the data only, no actual compression is performed.

    Declaration

    Objective-C

    - (NTBinaryData *)compressToInternal;

    Return Value

    A byte vector of the serialized data.

  • Returns resized version of the bitmap. The power of two padding added during the construction of this bitmap will be removed prior to resizing. If the power of two conversion flag is set, new padding will be added to the image after resizing to make it’s dimensions power of two.

    Declaration

    Objective-C

    - (NTBitmap *)getResizedBitmap:(unsigned int)width height:(unsigned int)height;

    Parameters

    width

    The new width of this bitmap.

    height

    The new height of this bitmap.

    Return Value

    The resized bitmap instance or null in case of error (wrong dimensions).

  • Returns sub-bitmap with specified offsets and dimensions.

    Declaration

    Objective-C

    - (NTBitmap *)getSubBitmap:(int)xOffset
                       yOffset:(int)yOffset
                         width:(int)width
                        height:(int)height;

    Parameters

    xOffset

    X coordinate offset in the bitmap.

    yOffset

    Y coordinate offset in the bitmap.

    width

    Width of the sub-bitmap.

    height

    Height of the sub-bitmap.

    Return Value

    Sub-bitmap instance or null in case of error (wrong dimensions).

  • Returns paddedsub-bitmap with specified offsets and dimensions.

    Declaration

    Objective-C

    - (NTBitmap *)getPaddedBitmap:(int)xPadding yPadding:(int)yPadding;

    Parameters

    xPadding

    Padding along X coordinate. If negative value is used, the bitmap is padded from the left. By default, bitmap is padded from the right.

    yPadding

    Padding along Y coordinate. If negative value is used, the bitmap is padded from the top. By default, bitmap is padded from the bottom.

    Return Value

    Padded bitmap instance or null in case of error (wrong dimensions).

  • Returns copy of the bitmap converted to RGBA format.

    Declaration

    Objective-C

    - (NTBitmap *)getRGBABitmap;

    Return Value

    The bitmap with identical dimensions but converted to RGBA format.

  • Creates a new bitmap from compressed byte vector. If the power of two conversion flag is set, additional padding will be added to the image to make it’s dimensions power of two.

    Declaration

    Objective-C

    + (NTBitmap *)createFromCompressed:(NTBinaryData *)compressedData;

    Parameters

    compressedData

    The compressed bitmap data.

    Return Value

    The bitmap created from the compressed data. If the decompression fails, null is returned.

  • Undocumented

    Declaration

    Objective-C

    -(void)dealloc;