MBBitmapPixelPlane Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | MBBitmapPixelPlane.h |
Overview
Represents a plane of pixels that can be accessed individually, regardless of the underlying pixel format. This allows code to access and manipulate bitmaps without needing to worry about the internal representation of the pixels.
Important:
- This class supports only integral pixels.
- This class does not currently support floating-point channel values.
- This class is only intended for use with iOS-compatible bitmaps.
Accessing bitmap information
pixelCount
Returns the number of pixels in the bitmap.
@property (nonatomic, readonly) NSUInteger pixelCountDeclared In
MBBitmapPixelPlane.h
columnCount
Returns the number of columns in the bitmap.
@property (nonatomic, readonly) NSUInteger columnCountDeclared In
MBBitmapPixelPlane.h
rowCount
Returns the number of rows in the bitmap.
@property (nonatomic, readonly) NSUInteger rowCountDeclared In
MBBitmapPixelPlane.h
channelsPerPixel
Returns the number of color channels for each pixel in the bitmap.
@property (nonatomic, readonly) NSUInteger channelsPerPixelDeclared In
MBBitmapPixelPlane.h
channelMaximumValue
Returns the maximum value of an individual color component in the bitmap.
@property (nonatomic, readonly) MBColorComponent channelMaximumValueDeclared In
MBBitmapPixelPlane.h
bytesPerPixel
Returns the number of bytes required to represent each pixel in the bitmap.
@property (nonatomic, readonly) NSUInteger bytesPerPixelDeclared In
MBBitmapPixelPlane.h
sizeInBytes
Returns the number of bytes required to represent the bitmap.
@property (nonatomic, readonly) NSUInteger sizeInBytesDeclared In
MBBitmapPixelPlane.h
pixelType
Returns a MBBitmapPixelType value indicating how the bitmap
interprets pixel data.
@property (nonatomic, readonly) MBBitmapPixelType pixelTypeDeclared In
MBBitmapPixelPlane.h
Creating empty bitmaps
+ bitmapWithColumns:rows:
Creates a new MBBitmapPixelPlane containing the specified number of
rows and columns.
+ (nullable instancetype)bitmapWithColumns:(NSUInteger)cols rows:(NSUInteger)rowsParameters
cols |
The number of pixel columns in the returned bitmap. |
|---|---|
rows |
The number of pixel rows in the returned bitmap. |
Return Value
A new MBBitmapPixelPlane instance with the specified settings.
Returns nil if an error occurred.
Discussion
The bitmap will use the device color space with 4 channel pixels (RGBA) having 8 bits per channel using the device’s native byte ordering.
Declared In
MBBitmapPixelPlane.h
+ bitmapWithSize:
Creates a new MBBitmapPixelPlane containing the specified number of
rows and columns.
+ (nullable instancetype)bitmapWithSize:(CGSize)sizeParameters
size |
The size, in pixels, of the returned bitmap. Only integral values are used; fractional values encountered for the width or height will be rounded up to the next integer value. |
|---|
Return Value
A new MBBitmapPixelPlane instance with the specified settings.
Returns nil if an error occurred.
Discussion
The bitmap will use the device color space with 4 channel pixels (RGBA) having 8 bits per channel using the device’s native byte ordering.
Declared In
MBBitmapPixelPlane.h
+ bitmapWithSize:bitsPerChannel:colorSpace:bitmapInfo:
Creates a new MBBitmapPixelPlane having the specified settings.
+ (nullable instancetype)bitmapWithSize:(CGSize)size bitsPerChannel:(NSUInteger)bits colorSpace:(nonnull CGColorSpaceRef)space bitmapInfo:(CGBitmapInfo)infoParameters
size |
The size, in pixels, of the returned bitmap. Only integral values are used; fractional values encountered for the width or height will be rounded up to the next integer value. |
|---|---|
bits |
The number of bits per color channel. |
space |
The color space that will be used by the bitmap. |
info |
The |
Return Value
A new MBBitmapPixelPlane instance with the specified settings.
Returns nil if an error occurred.
Declared In
MBBitmapPixelPlane.h
+ bitmapWithUIImage:
Creates a new MBBitmapPixelPlane populated using the content of the image
data contained in the UIImage instance provided.
+ (nullable instancetype)bitmapWithUIImage:(nonnull UIImage *)imageParameters
image |
An image that will be used as the source content of the
returned |
|---|
Return Value
A new MBBitmapPixelPlane instance containing the image specified.
Returns nil if an error occurred.
Declared In
MBBitmapPixelPlane.h
+ bitmapWithNSImage:
Creates a new MBBitmapPixelPlane populated using the content of the image
data contained in the NSImage instance provided.
+ (nullable instancetype)bitmapWithNSImage:(nonnull NSImage *)imageParameters
image |
An image that will be used as the source content of the
returned |
|---|
Return Value
A new MBBitmapPixelPlane instance containing the image specified.
Returns nil if an error occurred.
Declared In
MBBitmapPixelPlane.h
+ bitmapWithCGImage:
Creates a new MBBitmapPixelPlane populated using the content of the image
data contained in the CGImageRef provided.
+ (nullable instancetype)bitmapWithCGImage:(nonnull CGImageRef)imageParameters
image |
An image that will be used as the source content of the
returned |
|---|
Return Value
A new MBBitmapPixelPlane instance containing the image specified.
Returns nil if an error occurred.
Declared In
MBBitmapPixelPlane.h
+ bitmapWithBitmapContext:
Creates a new MBBitmapPixelPlane populated using the content of the bitmap
image data contained in the CGContextRef provided.
+ (nullable instancetype)bitmapWithBitmapContext:(nonnull CGContextRef)bitmapParameters
bitmap |
A CoreGraphics context that will be used as the source
content of the returned |
|---|
Return Value
A new MBBitmapPixelPlane instance containing the image specified.
Returns nil if an error occurred.
Declared In
MBBitmapPixelPlane.h
Getting individual pixel data
– getPixel:atColumn:row:
Retrieves the color channel values for the pixel at the specified column (x coordinate) and row (y coordinate).
- (BOOL)getPixel:(nonnull inout MBBitmapPixel *)pixelPtr atColumn:(NSUInteger)col row:(NSUInteger)rowParameters
pixelPtr |
A pointer to an |
|---|---|
col |
The column of the pixel whose color data is being retrieved. |
row |
The row of the pixel whose color data is being retrieved. |
Return Value
YES on success. NO will be returned if pixel is nil or if
the specified pixel falls outside the bounds of the bitmap.
Declared In
MBBitmapPixelPlane.h
– getPixel:atPoint:
Retrieves the color channel values for the pixel at the specified point.
- (BOOL)getPixel:(nonnull inout MBBitmapPixel *)pixelPtr atPoint:(CGPoint)pointParameters
pixelPtr |
A pointer to an |
|---|---|
point |
The point specifying the x and y coordinates of the pixel whose color data is being retrieved. Only integral values are used; fractional values encountered for the x or y coordinate will be rounded to the closest integer value. |
Return Value
YES on success. NO will be returned if pixel is nil or if
the specified pixel falls outside the bounds of the bitmap.
Declared In
MBBitmapPixelPlane.h
– getPixel:atIndex:
Retrieves the color channel values for the pixel at the specified index.
- (BOOL)getPixel:(nonnull inout MBBitmapPixel *)pixelPtr atIndex:(NSUInteger)indexParameters
pixelPtr |
A pointer to an |
|---|---|
index |
The index of the pixel in the bitmap. The top-left pixel
is index |
Return Value
YES on success. NO will be returned if pixel is nil or if
the specified pixel falls outside the bounds of the bitmap.
Declared In
MBBitmapPixelPlane.h
Setting individual pixel data
– setPixel:atColumn:row:
Sets the color channel values for the pixel at the specified column (x coordinate) and row (y coordinate).
- (BOOL)setPixel:(MBBitmapPixel)pixel atColumn:(NSUInteger)col row:(NSUInteger)rowParameters
pixel |
The |
|---|---|
col |
The column of the pixel whose color data is being retrieved. |
row |
The row of the pixel whose color data is being retrieved. |
Return Value
YES on success. NO will be returned if the specified pixel
falls outside the bounds of the bitmap.
Discussion
Values provided in channels not supported by the underlying bitmap will be ignored.
Declared In
MBBitmapPixelPlane.h
– setPixel:atPoint:
Sets the color channel values for the pixel at the specified point.
- (BOOL)setPixel:(MBBitmapPixel)pixel atPoint:(CGPoint)pointParameters
pixel |
The |
|---|---|
point |
The point specifying the x and y coordinates of the pixel whose color data is being set. Only integral values are used; fractional values encountered for the x or y coordinate will be rounded to the closest integer value. |
Return Value
YES on success. NO will be returned if the specified pixel
falls outside the bounds of the bitmap.
Discussion
Values provided in channels not supported by the underlying bitmap will be ignored.
Declared In
MBBitmapPixelPlane.h
– setPixel:atIndex:
Sets the color channel values for the pixel at the specified index.
- (BOOL)setPixel:(MBBitmapPixel)pixel atIndex:(NSUInteger)indexParameters
pixel |
The |
|---|---|
index |
The index of the pixel in the bitmap. The top-left pixel
is index |
Return Value
YES on success. NO will be returned if the specified pixel
falls outside the bounds of the bitmap.
Discussion
Values provided in channels not supported by the underlying bitmap will be ignored.
Declared In
MBBitmapPixelPlane.h
– image
Creates a UIImage instance containing a visual representation of the current
contents of the receiver.
- (nonnull UIImage *)imageReturn Value
A new UIImage.
Declared In
MBBitmapPixelPlane.h