zakkhoyt / ColorPicKit

A collection of UIControls for picking colors on iPhone, iPad, and other iOS devices. Gradient slider, Hue slider, RGB sliders, HSB sliders, CMYK sliders, ImagePixelPicker, HSB Wheel, HSB Spectrum. Color related class extensions
MIT License
15 stars 4 forks source link

Expose functions of UIImage for getting color of pixel at point #6

Closed zakkhoyt closed 7 years ago

zakkhoyt commented 7 years ago

// A one line call to retrieve color of a pixel public func pixelColorAt(point: CGPoint) -> UIColor?

// UIImage to pixel buffer in one line call public func pixelBuffer() -> CVPixelBuffer public func pixelBuffer() -> (pixelBuffer: CVPixelBuffer, size:CGSize, bytesPerRow: CGFloat)

Also add class function variants

zakkhoyt commented 7 years ago

I added the following public class methods:

    public class func pixelBufferOf(image: UIImage) -> CVPixelBuffer? 
    public class func pixelBufferPropertiesOf(image: UIImage) -> (pixelBuffer: CVPixelBuffer?, size:CGSize, bytesPerRow: Int) 
    public class func getSizeOf(pixelBuffer: CVPixelBuffer) -> CGSize 
    public class func getBytesPerRowOf(pixelBuffer: CVPixelBuffer) -> Int
    public class func pixelColorOf(image: UIImage, at point: CGPoint) -> UIColor? 

and their matching instance methods

public func pixelBuffer() -> CVPixelBuffer? {
public func pixelColorAt(point: CGPoint) -> UIColor? {
public func pixelBufferProperties() -> (pixelBuffer: CVPixelBuffer?, size:CGSize, bytesPerRow: Int) {