---
title: makeImage()
framework: coregraphics
role: symbol
role_heading: Instance Method
path: coregraphics/cgcontext/makeimage()
---

# makeImage()

Creates and returns a CGImage from the pixel data in a bitmap graphics context.

## Declaration

```swift
func makeImage() -> CGImage?
```

## Return Value

Return Value A CGImage object that contains a snapshot of the bitmap graphics context or NULL if the image is not created.

## Discussion

Discussion The CGImage object returned by this function is created by a copy operation. Subsequent changes to the bitmap graphics context do not affect the contents of the returned image. In some cases the copy operation actually follows copy-on-write semantics, so that the actual physical copy of the bits occur only if the underlying data in the bitmap graphics context is modified. As a consequence, you may want to use the resulting image and release it before you perform additional drawing into the bitmap graphics context. In this way, you can avoid the actual physical copy of the data.

## See Also

### Managing a Bitmap Graphics Context

- [bitmapInfo](coregraphics/cgcontext/bitmapinfo.md)
- [alphaInfo](coregraphics/cgcontext/alphainfo.md)
- [bitsPerComponent](coregraphics/cgcontext/bitspercomponent.md)
- [bitsPerPixel](coregraphics/cgcontext/bitsperpixel.md)
- [bytesPerRow](coregraphics/cgcontext/bytesperrow.md)
- [colorSpace](coregraphics/cgcontext/colorspace.md)
- [data](coregraphics/cgcontext/data.md)
- [height](coregraphics/cgcontext/height.md)
- [width](coregraphics/cgcontext/width.md)
