У меня проблема.Мои точки (GCRect) не будут рисоваться на моем CGImage.Координаты верны, хотя.
Вот мой код
public func drawFaceDots (onImage image : CGImage) -> CGImage {
let faceRect = CGRect(x: 0, y: 0, width: image.width, height: image.height)
let diameter : CGFloat = 5
print(faceRect)
let context = CGContext(data: nil, width: image.width, height: image.height, bitsPerComponent: 8, bytesPerRow: 4 * image.width, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue)!
//context.draw(image, in: faceRect)
context.setFillColor(NSColor.red.cgColor)
for point in self.orignalFace! {
print("Point(\(point.x);\(point.y))")
let widthX = point.x * CGFloat(image.width) + diameter
let heightY = point.y * CGFloat(image.height) + diameter
let boundingRect = CGRect(x: CGFloat(image.width) * point.x, y: CGFloat(image.height) * point.y, width: widthX, height: heightY)
print("BoundingRect : \(boundingRect))")
context.addEllipse(in: boundingRect)
context.setFillColor(NSColor.green.cgColor)
}
return context.makeImage()!
}
Кто-нибудь может мне помочь?