<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBitmapImageRep",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBitmapImageRep"
  },
  "title" : "NSBitmapImageRep"
}
-->

# NSBitmapImageRep

An object that renders an image from bitmap data.

```
class NSBitmapImageRep
```

## 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 [`NSBitmapImageRep`](/documentation/AppKit/NSBitmapImageRep) 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 <doc://com.apple.documentation/documentation/CoreGraphics/CGImage/init(width:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:)> function and <doc://com.apple.documentation/documentation/CoreGraphics/CGImageAlphaInfo/last> parameter.) Alternatively, include the [`NSAlphaNonpremultipliedBitmapFormat`](/documentation/AppKit/NSAlphaNonpremultipliedBitmapFormat) flag when creating the bitmap.

> Note:
> Use the `bitmapFormat` parameter to the ``doc://com.apple.appkit/documentation/AppKit/NSBitmapImageRep/init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:)`` 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 ``doc://com.apple.appkit/documentation/AppKit/NSBitmapImageRep/bitmapFormat`` property before working with image data.

## Topics

### Creating Bitmap Representations of Images

[`imageRepWithData:`](/documentation/AppKit/NSBitmapImageRep/imageRepWithData:)

Creates and returns a bitmap image representation with the first image in the specified data.

[`imageReps(with:)`](/documentation/AppKit/NSBitmapImageRep/imageReps(with:))

Creates and returns an array of bitmap image representation objects that correspond to the images in the specified data.

[`colorize(byMappingGray:to:blackMapping:whiteMapping:)`](/documentation/AppKit/NSBitmapImageRep/colorize(byMappingGray:to:blackMapping:whiteMapping:))

Colorizes a grayscale image.

[`init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:)`](/documentation/AppKit/NSBitmapImageRep/init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:))

Initializes a newly allocated bitmap image representation so it can render the specified image.

[`init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:)`](/documentation/AppKit/NSBitmapImageRep/init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:))

Initializes a newly allocated bitmap image representation so it can render the specified image.

[`init(cgImage:)`](/documentation/AppKit/NSBitmapImageRep/init(cgImage:)-7o5tz)

Returns a bitmap image representation from a Core Graphics image object.

[`init(ciImage:)`](/documentation/AppKit/NSBitmapImageRep/init(ciImage:)-7bi19)

Returns a bitmap image representation from a Core Image object.

[`init(data:)`](/documentation/AppKit/NSBitmapImageRep/init(data:))

Initializes a newly allocated bitmap image representation from the specified data.

[`init(forIncrementalLoad:)`](/documentation/AppKit/NSBitmapImageRep/init(forIncrementalLoad:))

Initializes a newly allocated bitmap image representation for incremental loading.

[`init(focusedViewRect:)`](/documentation/AppKit/NSBitmapImageRep/init(focusedViewRect:))

Initializes a newly allocated bitmap image representation with bitmap data from a rendered image.

### Getting Information About Images

[`bitmapFormat`](/documentation/AppKit/NSBitmapImageRep/bitmapFormat)

The format of the bitmap image representation.

[`NSBitmapImageRep.Format`](/documentation/AppKit/NSBitmapImageRep/Format)

Constants that represent bitmap component formats.

[`bitsPerPixel`](/documentation/AppKit/NSBitmapImageRep/bitsPerPixel)

The number of bits allocated for each pixel in each plane of data.

[`bytesPerPlane`](/documentation/AppKit/NSBitmapImageRep/bytesPerPlane)

The number of bytes in each plane or channel of data.

[`bytesPerRow`](/documentation/AppKit/NSBitmapImageRep/bytesPerRow)

The minimum number of bytes required to specify a scan line in each data plane.

[`isPlanar`](/documentation/AppKit/NSBitmapImageRep/isPlanar)

A Boolean value that indicates whether the image data is in a planar configuration.

[`numberOfPlanes`](/documentation/AppKit/NSBitmapImageRep/numberOfPlanes)

The number of separate planes into which the image data is organized.

[`samplesPerPixel`](/documentation/AppKit/NSBitmapImageRep/samplesPerPixel)

The number of components for each pixel.

### Getting the Bitmap Data

[`bitmapData`](/documentation/AppKit/NSBitmapImageRep/bitmapData)

A pointer to the bitmap data.

[`getBitmapDataPlanes(_:)`](/documentation/AppKit/NSBitmapImageRep/getBitmapDataPlanes(_:))

Returns by indirection bitmap data of the bitmap image representation separated into planes.

### Producing Other Representations of Images

[`tiffRepresentationOfImageReps(in:)`](/documentation/AppKit/NSBitmapImageRep/tiffRepresentationOfImageReps(in:))

Returns a TIFF representation of the specified images.

[`tiffRepresentationOfImageReps(in:using:factor:)`](/documentation/AppKit/NSBitmapImageRep/tiffRepresentationOfImageReps(in:using:factor:))

Returns a TIFF representation of the specified images using the specified compression scheme and factor.

[`tiffRepresentation`](/documentation/AppKit/NSBitmapImageRep/tiffRepresentation)

A TIFF representation of the bitmap image data.

[`tiffRepresentation(using:factor:)`](/documentation/AppKit/NSBitmapImageRep/tiffRepresentation(using:factor:))

Returns a TIFF representation of the image using the specified compression.

[`representationOfImageReps(in:using:properties:)`](/documentation/AppKit/NSBitmapImageRep/representationOfImageReps(in:using:properties:))

Formats the specified bitmap images using the specified storage type and properties and returns them in a data object.

[`representation(using:properties:)`](/documentation/AppKit/NSBitmapImageRep/representation(using:properties:))

Formats the bitmap representation’s image data using the specified storage type and properties and returns it in a data object.

[`NSDrawBitmap(_:_:_:_:_:_:_:_:_:_:_:)`](/documentation/AppKit/NSDrawBitmap(_:_:_:_:_:_:_:_:_:_:_:))

Draws a bitmap image.

### Managing Compression Types

[`getTIFFCompressionTypes(_:count:)`](/documentation/AppKit/NSBitmapImageRep/getTIFFCompressionTypes(_:count:))

Returns by indirection an array of all available compression types that can be used when writing a TIFF image.

[`localizedName(forTIFFCompressionType:)`](/documentation/AppKit/NSBitmapImageRep/localizedName(forTIFFCompressionType:))

Returns an autoreleased string containing the localized name for the specified compression type.

[`canBeCompressed(using:)`](/documentation/AppKit/NSBitmapImageRep/canBeCompressed(using:))

Tests whether the bitmap image representation can be compressed by the specified compression scheme.

[`setCompression(_:factor:)`](/documentation/AppKit/NSBitmapImageRep/setCompression(_:factor:))

Sets the bitmap image representation’s compression type and compression factor.

[`getCompression(_:factor:)`](/documentation/AppKit/NSBitmapImageRep/getCompression(_:factor:))

Returns by indirection the bitmap image representation’s compression type and compression factor.

[`setProperty(_:withValue:)`](/documentation/AppKit/NSBitmapImageRep/setProperty(_:withValue:))

Sets the specified property of the bitmap image representation to the specified value.

[`value(forProperty:)`](/documentation/AppKit/NSBitmapImageRep/value(forProperty:))

Returns the value for the specified property.

[`NSBitmapImageRep.TIFFCompression`](/documentation/AppKit/NSBitmapImageRep/TIFFCompression)

Constants that represent the supported TIFF data-compression schemes.

[`NSBitmapImageRep.PropertyKey`](/documentation/AppKit/NSBitmapImageRep/PropertyKey)

Constants that identify bitmap image representation properties.

### Loading Images Incrementally

[`incrementalLoad(from:complete:)`](/documentation/AppKit/NSBitmapImageRep/incrementalLoad(from:complete:))

Loads the current image data into an incrementally-loaded image representation and returns the current status of the image.

[`NSBitmapImageRep.LoadStatus`](/documentation/AppKit/NSBitmapImageRep/LoadStatus)

Constants that identify the loading status of the image.

### Managing Pixel Values

[`setColor(_:atX:y:)`](/documentation/AppKit/NSBitmapImageRep/setColor(_:atX:y:))

Changes the color of the pixel at the specified coordinates.

[`colorAt(x:y:)`](/documentation/AppKit/NSBitmapImageRep/colorAt(x:y:))

Returns the color of the pixel at the specified coordinates.

[`setPixel(_:atX:y:)`](/documentation/AppKit/NSBitmapImageRep/setPixel(_:atX:y:))

Sets the bitmap image representation’s pixel at the specified coordinates to the specified raw pixel values.

[`getPixel(_:atX:y:)`](/documentation/AppKit/NSBitmapImageRep/getPixel(_:atX:y:))

Returns by indirection the pixel data for the specified location in the bitmap image representation.

### Getting Core Graphics Images

[`cgImage`](/documentation/AppKit/NSBitmapImageRep/cgImage)

A Core Graphics image object based on the bitmap image representation’s data.

### Managing Color Spaces

[`converting(to:renderingIntent:)`](/documentation/AppKit/NSBitmapImageRep/converting(to:renderingIntent:))

Converts the bitmap image representation to the specified color space.

[`retagging(with:)`](/documentation/AppKit/NSBitmapImageRep/retagging(with:))

Changes the color space tag of the bitmap image representation.

[`colorSpace`](/documentation/AppKit/NSBitmapImageRep/colorSpace)

The color space of the bitmap.

### Constants

[`NSBitmapImageRep.FileType`](/documentation/AppKit/NSBitmapImageRep/FileType)

Constants that specify bitmap file types.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)