<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGImage",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@T@CGImageRef"
  },
  "title" : "CGImage"
}
-->

# CGImage

A bitmap image or image mask.

```
class CGImage
```

## 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:)`](/documentation/CoreGraphics/CGImage/init(width:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:))

Creates a bitmap image from data supplied by a data provider.

[`init(jpegDataProviderSource:decode:shouldInterpolate:intent:)`](/documentation/CoreGraphics/CGImage/init(jpegDataProviderSource:decode:shouldInterpolate:intent:))

Creates a bitmap image using JPEG-encoded data supplied by a data provider.

[`init(pngDataProviderSource:decode:shouldInterpolate:intent:)`](/documentation/CoreGraphics/CGImage/init(pngDataProviderSource:decode:shouldInterpolate:intent:))

Creates a bitmap image using PNG-encoded data supplied by a data provider.

[`init(headroom:width:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:)`](/documentation/CoreGraphics/CGImage/init(headroom:width:height:bitsPerComponent:bitsPerPixel:bytesPerRow:space:bitmapInfo:provider:decode:shouldInterpolate:intent:))

### Retaining and releasing images

[`CGImageRetain`](/documentation/CoreGraphics/CGImageRetain)

Increments the retain count of a bitmap image.

[`CGImageRelease`](/documentation/CoreGraphics/CGImageRelease)

Decrements the retain count of a bitmap image.

### Examining an image

[`isMask`](/documentation/CoreGraphics/CGImage/isMask)

Returns whether a bitmap image is an image mask.

[`width`](/documentation/CoreGraphics/CGImage/width)

Returns the width of a bitmap image, in pixels.

[`height`](/documentation/CoreGraphics/CGImage/height)

Returns the height of a bitmap image.

[`bitsPerComponent`](/documentation/CoreGraphics/CGImage/bitsPerComponent)

Returns the number of bits allocated for a single color component of a bitmap image.

[`bitsPerPixel`](/documentation/CoreGraphics/CGImage/bitsPerPixel)

Returns the number of bits allocated for a single pixel in a bitmap image.

[`bytesPerRow`](/documentation/CoreGraphics/CGImage/bytesPerRow)

Returns the number of bytes allocated for a single row of a bitmap image.

[`colorSpace`](/documentation/CoreGraphics/CGImage/colorSpace)

Return the color space for a bitmap image.

[`alphaInfo`](/documentation/CoreGraphics/CGImage/alphaInfo)

Returns the alpha channel information for a bitmap image.

[`CGImageAlphaInfo`](/documentation/CoreGraphics/CGImageAlphaInfo)

Storage options for alpha component data.

[`dataProvider`](/documentation/CoreGraphics/CGImage/dataProvider)

Returns the data provider for a bitmap image or image mask.

[`decode`](/documentation/CoreGraphics/CGImage/decode)

Returns the decode array for a bitmap image.

[`shouldInterpolate`](/documentation/CoreGraphics/CGImage/shouldInterpolate)

Returns the interpolation setting for a bitmap image.

[`renderingIntent`](/documentation/CoreGraphics/CGImage/renderingIntent)

Returns the rendering intent setting for a bitmap image.

[`bitmapInfo`](/documentation/CoreGraphics/CGImage/bitmapInfo)

Returns the bitmap information for a bitmap image.

[`CGBitmapInfo`](/documentation/CoreGraphics/CGBitmapInfo)

Component information for a bitmap image.

[`utType`](/documentation/CoreGraphics/CGImage/utType)

The Universal Type Identifier for the image.

### Copying an image

[`copy()`](/documentation/CoreGraphics/CGImage/copy())

Creates a copy of a bitmap image.

[`copy(colorSpace:)`](/documentation/CoreGraphics/CGImage/copy(colorSpace:))

Creates a copy of a bitmap image, replacing its colorspace.

### Creating images by modifying an image

[`cropping(to:)`](/documentation/CoreGraphics/CGImage/cropping(to:))

Creates a bitmap image using the data contained within a subregion of an existing bitmap image.

[`masking(_:)`](/documentation/CoreGraphics/CGImage/masking(_:))

Creates a bitmap image from an existing image and an image mask.

[`copy(maskingColorComponents:)`](/documentation/CoreGraphics/CGImage/copy(maskingColorComponents:))

### Creating image masks

[`init(maskWidth:height:bitsPerComponent:bitsPerPixel:bytesPerRow:provider:decode:shouldInterpolate:)`](/documentation/CoreGraphics/CGImage/init(maskWidth:height:bitsPerComponent:bitsPerPixel:bytesPerRow:provider:decode:shouldInterpolate:))

Creates a bitmap image mask from data supplied by a data provider.

[`CGImageCreateWithMaskingColors`](/documentation/CoreGraphics/CGImageCreateWithMaskingColors)

Creates a bitmap image by masking an existing bitmap image with the provided color values.

### Adopting high dynamic range (HDR)

[Enhancing high dynamic range image rendering](/documentation/CoreGraphics/adopting-advancements-in-hdr-image-rendering)

Improve your app’s High Dynamic Range (HDR) image support with metadata.

[`contentHeadroom`](/documentation/CoreGraphics/CGImage/contentHeadroom)

[`calculatedContentHeadroom`](/documentation/CoreGraphics/CGImage/calculatedContentHeadroom)

[`contentAverageLightLevel`](/documentation/CoreGraphics/CGImage/contentAverageLightLevel)

[`calculatedContentAverageLightLevel`](/documentation/CoreGraphics/CGImage/calculatedContentAverageLightLevel)

[`copy(contentAverageLightLevel:)`](/documentation/CoreGraphics/CGImage/copy(contentAverageLightLevel:))

[`copyWithCalculatedHDRStats()`](/documentation/CoreGraphics/CGImage/copyWithCalculatedHDRStats())

### Constants

[`CGImageAlphaInfo`](/documentation/CoreGraphics/CGImageAlphaInfo)

Storage options for alpha component data.

[`CGBitmapInfo`](/documentation/CoreGraphics/CGBitmapInfo)

Component information for a bitmap image.

[Host Endian Bitmap Formats](/documentation/CoreGraphics/host-endian-bitmap-formats)

Bit-depth constants for image bitmaps in host-endian byte order.

### Working with Core Foundation types

[`typeID`](/documentation/CoreGraphics/CGImage/typeID)

Returns the type identifier for CGImage objects.

### Instance properties

[`byteOrderInfo`](/documentation/CoreGraphics/CGImage/byteOrderInfo)

[`containsImageSpecificToneMappingMetadata`](/documentation/CoreGraphics/CGImage/containsImageSpecificToneMappingMetadata)

[`contentHeadroom`](/documentation/CoreGraphics/CGImage/contentHeadroom)

[`pixelFormatInfo`](/documentation/CoreGraphics/CGImage/pixelFormatInfo)

[`shouldToneMap`](/documentation/CoreGraphics/CGImage/shouldToneMap)

## See Also

  [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066)



---

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)