             return nil
         }
         
-        imageContext.draw(cgImage, CGRect(origin: .zero, size: size))
+        imageContext.draw(cgImage, in: CGRect(origin: .zero, size: image.size))
         
         pixels = UnsafeMutableBufferPointer<Pixel>(start: imageData, count: width * height)
     }

        }
        
        let address = y * width + x
        return pixels?[address]
    }
}


            return nil
        }
        
        width = Int(image.size.width)
        height = Int(image.size.height)
        
        let bytesPerRow = width * 4
        let imageData = UnsafeMutablePointer<Pixel>.allocate(capacity: width * height)
        let colorSpace = CGColorSpaceCreateDeviceRGB()
        
        var bitmapInfo: UInt32 = CGBitmapInfo.byteOrder32Big.rawValue
