---
title: NSBitmapImageRep
framework: appkit
role: symbol
role_heading: Class
path: appkit/nsbitmapimagerep
---

# NSBitmapImageRep

An object that renders an image from bitmap data.

## Declaration

```swift
class NSBitmapImageRep
```

## Overview

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 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:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:) function and CGImageAlphaInfo.last parameter.) Alternatively, include the NSAlphaNonpremultipliedBitmapFormat flag when creating the bitmap. note: Use the bitmapFormat parameter to the 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 bitmapFormat property before working with image data.

## Topics

### Creating Bitmap Representations of Images

- [imageReps(with:)](appkit/nsbitmapimagerep/imagereps(with:).md)
- [colorize(byMappingGray:to:blackMapping:whiteMapping:)](appkit/nsbitmapimagerep/colorize(bymappinggray:to:blackmapping:whitemapping:).md)
- [init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:)](appkit/nsbitmapimagerep/init(bitmapdataplanes:pixelswide:pixelshigh:bitspersample:samplesperpixel:hasalpha:isplanar:colorspacename:bitmapformat:bytesperrow:bitsperpixel:).md)
- [init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:)](appkit/nsbitmapimagerep/init(bitmapdataplanes:pixelswide:pixelshigh:bitspersample:samplesperpixel:hasalpha:isplanar:colorspacename:bytesperrow:bitsperpixel:).md)
- [init(cgImage:)](appkit/nsbitmapimagerep/init(cgimage:)-7o5tz.md)
- [init(ciImage:)](appkit/nsbitmapimagerep/init(ciimage:)-7bi19.md)
- [init(data:)](appkit/nsbitmapimagerep/init(data:).md)
- [init(forIncrementalLoad:)](appkit/nsbitmapimagerep/init(forincrementalload:).md)
- [init(focusedViewRect:)](appkit/nsbitmapimagerep/init(focusedviewrect:).md)

### Getting Information About Images

- [bitmapFormat](appkit/nsbitmapimagerep/bitmapformat.md)
- [NSBitmapImageRep.Format](appkit/nsbitmapimagerep/format.md)
- [bitsPerPixel](appkit/nsbitmapimagerep/bitsperpixel.md)
- [bytesPerPlane](appkit/nsbitmapimagerep/bytesperplane.md)
- [bytesPerRow](appkit/nsbitmapimagerep/bytesperrow.md)
- [isPlanar](appkit/nsbitmapimagerep/isplanar.md)
- [numberOfPlanes](appkit/nsbitmapimagerep/numberofplanes.md)
- [samplesPerPixel](appkit/nsbitmapimagerep/samplesperpixel.md)

### Getting the Bitmap Data

- [bitmapData](appkit/nsbitmapimagerep/bitmapdata.md)
- [getBitmapDataPlanes(_:)](appkit/nsbitmapimagerep/getbitmapdataplanes(_:).md)

### Producing Other Representations of Images

- [tiffRepresentationOfImageReps(in:)](appkit/nsbitmapimagerep/tiffrepresentationofimagereps(in:).md)
- [tiffRepresentationOfImageReps(in:using:factor:)](appkit/nsbitmapimagerep/tiffrepresentationofimagereps(in:using:factor:).md)
- [tiffRepresentation](appkit/nsbitmapimagerep/tiffrepresentation.md)
- [tiffRepresentation(using:factor:)](appkit/nsbitmapimagerep/tiffrepresentation(using:factor:).md)
- [representationOfImageReps(in:using:properties:)](appkit/nsbitmapimagerep/representationofimagereps(in:using:properties:).md)
- [representation(using:properties:)](appkit/nsbitmapimagerep/representation(using:properties:).md)
- [NSDrawBitmap(_:_:_:_:_:_:_:_:_:_:_:)](appkit/nsdrawbitmap(_:_:_:_:_:_:_:_:_:_:_:).md)

### Managing Compression Types

- [getTIFFCompressionTypes(_:count:)](appkit/nsbitmapimagerep/gettiffcompressiontypes(_:count:).md)
- [localizedName(forTIFFCompressionType:)](appkit/nsbitmapimagerep/localizedname(fortiffcompressiontype:).md)
- [canBeCompressed(using:)](appkit/nsbitmapimagerep/canbecompressed(using:).md)
- [setCompression(_:factor:)](appkit/nsbitmapimagerep/setcompression(_:factor:).md)
- [getCompression(_:factor:)](appkit/nsbitmapimagerep/getcompression(_:factor:).md)
- [setProperty(_:withValue:)](appkit/nsbitmapimagerep/setproperty(_:withvalue:).md)
- [value(forProperty:)](appkit/nsbitmapimagerep/value(forproperty:).md)
- [NSBitmapImageRep.TIFFCompression](appkit/nsbitmapimagerep/tiffcompression.md)
- [NSBitmapImageRep.PropertyKey](appkit/nsbitmapimagerep/propertykey.md)

### Loading Images Incrementally

- [incrementalLoad(from:complete:)](appkit/nsbitmapimagerep/incrementalload(from:complete:).md)
- [NSBitmapImageRep.LoadStatus](appkit/nsbitmapimagerep/loadstatus.md)

### Managing Pixel Values

- [setColor(_:atX:y:)](appkit/nsbitmapimagerep/setcolor(_:atx:y:).md)
- [colorAt(x:y:)](appkit/nsbitmapimagerep/colorat(x:y:).md)
- [setPixel(_:atX:y:)](appkit/nsbitmapimagerep/setpixel(_:atx:y:).md)
- [getPixel(_:atX:y:)](appkit/nsbitmapimagerep/getpixel(_:atx:y:).md)

### Getting Core Graphics Images

- [cgImage](appkit/nsbitmapimagerep/cgimage.md)

### Managing Color Spaces

- [converting(to:renderingIntent:)](appkit/nsbitmapimagerep/converting(to:renderingintent:).md)
- [retagging(with:)](appkit/nsbitmapimagerep/retagging(with:).md)
- [colorSpace](appkit/nsbitmapimagerep/colorspace.md)

### Constants

- [NSBitmapImageRep.FileType](appkit/nsbitmapimagerep/filetype.md)

### Initializers

- [init(CGImage:)](appkit/nsbitmapimagerep/init(cgimage:)-4e6yc.md)
- [init(CIImage:)](appkit/nsbitmapimagerep/init(ciimage:)-4ouvw.md)

## Relationships

### Inherits From

- [NSImageRep](appkit/nsimagerep.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Bitmap Formats

- [NSCIImageRep](appkit/nsciimagerep.md)
- [NSPICTImageRep](appkit/nspictimagerep.md)
