Reads the color of the pixel at the specified location.


func NSReadPixel(_ passedPoint: NSPoint) -> NSColor?



The pixel location to read, specified in the current coordinate system.

Return Value

The color of the pixel at the specified location.


Because the passedPoint parameter is relative to the current coordinate system, if you wish to read a pixel from a specific view, you must convert points in the view’s coordinate system to the current coordinate system before calling this function. Alternatively, you can lock focus on the view and then specify the pixel coordinate in the view’s coordinate system.

When mapping the specified point to pixel boundaries, this method rounds to the nearest pixel. For more information on how coordinate points map to the underlying pixels, see Coordinate Systems and Transforms in Cocoa Drawing Guide.

See Also

Auxiliary Functions

func NSSetShowsServicesMenuItem(String, Bool) -> Int

Specifies whether an item should be included in Services menus.

func NSCopyBits(Int, NSRect, NSPoint)

Copies a bitmap image to the location specified by a destination point.

func NSShowsServicesMenuItem(String) -> Bool

Specifies whether a Services menu item is currently enabled.

func NSDottedFrameRect(NSRect)

Draws a bordered rectangle.