An object that renders an image from bitmap data.
SDK
- macOS 10.0+
Framework
- App
Kit
Declaration
class NSBitmapImageRep : NSImage Rep
Overview
Supported bitmap data formats include GIF, JPEG, TIFF, PNG, and various permutations of raw bitmap data.
Alpha Premultiplication and Bitmap Formats
When creating a bitmap using a premultiplied format, if a coverage (alpha) plane exists, the bitmap’s color components are premultiplied with it. In this case, if you modify the contents of the bitmap, you are therefore responsible for premultiplying the data. Note that premultiplying generally has negligible effect on output quality. For floating-point image data, premultiplying color components is a lossless operation, but for fixed-point image data, premultiplication can introduce small rounding errors. In either case, more rounding errors may appear when compositing many premultiplied images; however, such errors are generally not readily visible.
For this reason, you should not use an NSBitmap
object if you want to manipulate image data. To work with data that is not premultiplied, use the Core Graphics framework instead. (Specifically, create images using the init(width:
function and CGImage
parameter.) Alternatively, include the NSAlpha
flag when creating the bitmap.
Note
Use the bitmap
parameter to the init(bitmap
method to specify the format for creating a bitmap. When creating or retrieving a bitmap with other methods, the bitmap format depends on the original source of the image data. Check the bitmap
property before working with image data.