---
title: "vImageGamma_PlanarFtoPlanar8(_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimagegamma_planarftoplanar8(_:_:_:_:)"
---

# vImageGamma_PlanarFtoPlanar8(_:_:_:_:)

Applies a gamma function to a 32-bit planar image to produce an 8-bit planar image.

## Declaration

```swift
func vImageGamma_PlanarFtoPlanar8(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ gamma: GammaFunction!, _ flags: vImage_Flags) -> vImage_Error
```

## Parameters

- `src`: The source vImage buffer.
- `dest`: A pointer to the destination vImage buffer structure. You’re responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, deallocate the memory to prevent memory leaks.
- `gamma`: The gamma function object.
- `flags`: The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageDoNotTile; otherwise, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageNoFlags.

## Return Value

Return Value kvImageNoError; otherwise, one of the error codes in Data Types and Constants.

## Discussion

Discussion This function maps floating-point values in the range 0.0...1.0 to the 8-bit range 0...255. let source = vImage.PixelBuffer<vImage.PlanarF>(     pixelValues: [  1 / 255,                     3 / 255,                     5 / 255,                    15 / 255,                    17 / 255,                    51 / 255 ] as [Float],     size: vImage.Size(width: 1, height: 6))

let destination = vImage.PixelBuffer<vImage.Planar8>(     size: source.size)

let gamma = vImageCreateGammaFunction(     1.0,     Int32(kvImageGamma_UseGammaValue),     vImage_Flags(kvImageNoFlags))

defer {     vImageDestroyGammaFunction(gamma) }

source.withUnsafePointerToVImageBuffer { src in     destination.withUnsafePointerToVImageBuffer { dest in                  _ = vImageGamma_PlanarFtoPlanar8(             src,             dest,             gamma,             vImage_Flags(kvImageNoFlags))              } }

// Prints "[1, 3, 5, 15, 17, 51]". print(destination.array)

## See Also

### Applying a gamma function

- [vImageCreateGammaFunction(_:_:_:)](accelerate/vimagecreategammafunction(_:_:_:).md)
- [Gamma function types](accelerate/1584480-gamma-function-types.md)
- [vImageGamma_Planar8toPlanarF(_:_:_:_:)](accelerate/vimagegamma_planar8toplanarf(_:_:_:_:).md)
- [vImageGamma_PlanarF(_:_:_:_:)](accelerate/vimagegamma_planarf(_:_:_:_:).md)
- [vImageDestroyGammaFunction(_:)](accelerate/vimagedestroygammafunction(_:).md)
- [Adjusting saturation and applying tone mapping](accelerate/adjusting-saturation-and-applying-tone-mapping.md)
