<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/makePixelBufferAndCGImageFormat(cgImage:pixelFormat:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVA2A24InitializableFromCGImageRzAA06StaticC6FormatRzrlE04makecd3AndgI002cgB005pixelI0AEy_xG0mD0_So01vb1_gI0V0lbI0tSo0G3Refa_xmtKFZ"
  },
  "title" : "makePixelBufferAndCGImageFormat(cgImage:pixelFormat:)"
}
-->

# makePixelBufferAndCGImageFormat(cgImage:pixelFormat:)

Returns a new pixel buffer and Core Graphics image format structure from a Core Graphics image.

```
static func makePixelBufferAndCGImageFormat(cgImage: CGImage, pixelFormat: Format.Type = Format.self) throws -> (pixelBuffer: vImage.PixelBuffer<Format>, cgImageFormat: vImage_CGImageFormat)
```

## Parameters

`cgImage`

The source Core Graphics image.

`pixelFormat`

The pixel format of the initialized buffer.

## Return Value

A new pixel buffer of type [`vImage.DynamicPixelFormat`](/documentation/Accelerate/vImage/DynamicPixelFormat) and a [`vImage_CGImageFormat`](/documentation/Accelerate/vImage_CGImageFormat) that describes the ordering and number of the color channels, the size and type of the data in the color channels, and whether or not the data is premultiplied by alpha.

## Discussion

Use this function where you know the bits per component and bits per pixel of the <doc://com.apple.documentation/documentation/CoreGraphics/CGImage> instance. These must match those of the buffer’s `pixelFormat`, otherwise this function returns `nil`.

---

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)