---
title: "colorize(byMappingGray:to:blackMapping:whiteMapping:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsbitmapimagerep/colorize(bymappinggray:to:blackmapping:whitemapping:)"
---

# colorize(byMappingGray:to:blackMapping:whiteMapping:)

Colorizes a grayscale image.

## Declaration

```swift
func colorize(byMappingGray midPoint: CGFloat, to midPointColor: NSColor?, blackMapping shadowColor: NSColor?, whiteMapping lightColor: NSColor?)
```

## Parameters

- `midPoint`: A float value representing the midpoint of the grayscale image.
- `midPointColor`: A color object representing the midpoint of the color to map the image to.
- `shadowColor`: A color object representing the black mapping to use for shadows.
- `lightColor`: A color object representing the white mapping to be used in the image.

## Discussion

Discussion This method maps the receiver such that: Gray value of midPoint –>  midPointColor; black –> shadowColor; white –> lightColor. It works on images with 8-bit SPP, and thus supports either 8-bit gray or 24-bit color (with optional alpha).

## See Also

### Creating Bitmap Representations of Images

- [imageReps(with:)](appkit/nsbitmapimagerep/imagereps(with:).md)
- [init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:)](appkit/nsbitmapimagerep/init(bitmapdataplanes:pixelswide:pixelshigh:bitspersample:samplesperpixel:hasalpha:isplanar:colorspacename:bitmapformat:bytesperrow:bitsperpixel:).md)
- [init(bitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:)](appkit/nsbitmapimagerep/init(bitmapdataplanes:pixelswide:pixelshigh:bitspersample:samplesperpixel:hasalpha:isplanar:colorspacename:bytesperrow:bitsperpixel:).md)
- [init(cgImage:)](appkit/nsbitmapimagerep/init(cgimage:)-7o5tz.md)
- [init(ciImage:)](appkit/nsbitmapimagerep/init(ciimage:)-7bi19.md)
- [init(data:)](appkit/nsbitmapimagerep/init(data:).md)
- [init(forIncrementalLoad:)](appkit/nsbitmapimagerep/init(forincrementalload:).md)
- [init(focusedViewRect:)](appkit/nsbitmapimagerep/init(focusedviewrect:).md)
