---
title: "makePixelBufferAndCGImageFormat(cgImage:pixelFormat:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vimage/pixelbuffer/makepixelbufferandcgimageformat(cgimage:pixelformat:)"
---

# makePixelBufferAndCGImageFormat(cgImage:pixelFormat:)

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

## Declaration

```swift
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

Return Value A new pixel buffer of type vImage.DynamicPixelFormat and a 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

Discussion Use this function where you know the bits per component and bits per pixel of the CGImage instance. These must match those of the buffer’s pixelFormat, otherwise this function returns nil.

## See Also

### Creating a pixel buffer and image format

- [makeDynamicPixelBufferAndCGImageFormat(cgImage:)](accelerate/vimage/pixelbuffer/makedynamicpixelbufferandcgimageformat(cgimage:).md)
