---
title: CGImage
framework: coregraphics
role: symbol
role_heading: Class
path: coregraphics/cgimage
---

# CGImage

A bitmap image or image mask.

## Declaration

```swift
class CGImage
```

## Overview

Overview A bitmap image is a rectangular array of pixels, each of which represents a single sample or data point from a source image.

## Topics

### Creating images

- [init(width:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:)](coregraphics/cgimage/init(width:height:bitspercomponent:bitsperpixel:bytesperrow:space:bitmapinfo:provider:decode:shouldinterpolate:intent:).md)
- [init(jpegDataProviderSource:decode:shouldInterpolate:intent:)](coregraphics/cgimage/init(jpegdataprovidersource:decode:shouldinterpolate:intent:).md)
- [init(pngDataProviderSource:decode:shouldInterpolate:intent:)](coregraphics/cgimage/init(pngdataprovidersource:decode:shouldinterpolate:intent:).md)
- [init(headroom:width:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:)](coregraphics/cgimage/init(headroom:width:height:bitspercomponent:bitsperpixel:bytesperrow:space:bitmapinfo:provider:decode:shouldinterpolate:intent:).md)

### Examining an image

- [isMask](coregraphics/cgimage/ismask.md)
- [width](coregraphics/cgimage/width.md)
- [height](coregraphics/cgimage/height.md)
- [bitsPerComponent](coregraphics/cgimage/bitspercomponent.md)
- [bitsPerPixel](coregraphics/cgimage/bitsperpixel.md)
- [bytesPerRow](coregraphics/cgimage/bytesperrow.md)
- [colorSpace](coregraphics/cgimage/colorspace.md)
- [alphaInfo](coregraphics/cgimage/alphainfo.md)
- [CGImageAlphaInfo](coregraphics/cgimagealphainfo.md)
- [dataProvider](coregraphics/cgimage/dataprovider.md)
- [decode](coregraphics/cgimage/decode.md)
- [shouldInterpolate](coregraphics/cgimage/shouldinterpolate.md)
- [renderingIntent](coregraphics/cgimage/renderingintent.md)
- [bitmapInfo](coregraphics/cgimage/bitmapinfo.md)
- [CGBitmapInfo](coregraphics/cgbitmapinfo.md)
- [utType](coregraphics/cgimage/uttype.md)

### Copying an image

- [copy()](coregraphics/cgimage/copy().md)
- [copy(colorSpace:)](coregraphics/cgimage/copy(colorspace:).md)

### Creating images by modifying an image

- [cropping(to:)](coregraphics/cgimage/cropping(to:).md)
- [masking(_:)](coregraphics/cgimage/masking(_:).md)
- [copy(maskingColorComponents:)](coregraphics/cgimage/copy(maskingcolorcomponents:).md)

### Creating image masks

- [init(maskWidth:height:bitsPerComponent:bitsPerPixel:bytesPerRow:provider:decode:shouldInterpolate:)](coregraphics/cgimage/init(maskwidth:height:bitspercomponent:bitsperpixel:bytesperrow:provider:decode:shouldinterpolate:).md)

### Adopting high dynamic range (HDR)

- [Enhancing high dynamic range image rendering](coregraphics/adopting-advancements-in-hdr-image-rendering.md)
- [contentHeadroom](coregraphics/cgimage/contentheadroom.md)
- [calculatedContentHeadroom](coregraphics/cgimage/calculatedcontentheadroom.md)
- [contentAverageLightLevel](coregraphics/cgimage/contentaveragelightlevel.md)
- [calculatedContentAverageLightLevel](coregraphics/cgimage/calculatedcontentaveragelightlevel.md)
- [copy(contentAverageLightLevel:)](coregraphics/cgimage/copy(contentaveragelightlevel:).md)
- [copyWithCalculatedHDRStats()](coregraphics/cgimage/copywithcalculatedhdrstats().md)

### Constants

- [CGImageAlphaInfo](coregraphics/cgimagealphainfo.md)
- [CGBitmapInfo](coregraphics/cgbitmapinfo.md)
- [Host Endian Bitmap Formats](coregraphics/host-endian-bitmap-formats.md)

### Working with Core Foundation types

- [typeID](coregraphics/cgimage/typeid.md)

### Instance properties

- [byteOrderInfo](coregraphics/cgimage/byteorderinfo.md)
- [containsImageSpecificToneMappingMetadata](coregraphics/cgimage/containsimagespecifictonemappingmetadata.md)
- [contentHeadroom](coregraphics/cgimage/contentheadroom.md)
- [pixelFormatInfo](coregraphics/cgimage/pixelformatinfo.md)
- [shouldToneMap](coregraphics/cgimage/shouldtonemap.md)

## Relationships

### Conforms To

- [AttachableAsImage](testing/attachableasimage.md)
- [Copyable](swift/copyable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Related Documentation

- [Quartz 2D Programming Guide](apple-archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction.md)

### 2D Drawing

- [CGContext](coregraphics/cgcontext.md)
- [CGPath](coregraphics/cgpath.md)
- [CGMutablePath](coregraphics/cgmutablepath.md)
- [CGLayer](coregraphics/cglayer.md)
