 		withSize size: CGSize,
 		scale: CGFloat,
 		opaque: Bool,
-		@noescape renderingBlock: (UIImage, CGContextRef) -> ())
+		@noescape renderingBlock: (image: UIImage, context: CGContextRef, contextSize: CGSize, imageDrawing: () -> ()) -> ())
 		-> UIImage
 	{
 		assert(size.width > 0 && size.height > 0, "Invalid size: \(size.width)x\(size.height)")

		let alphaInfo: CGImageAlphaInfo = (opaque) ? .NoneSkipLast : .PremultipliedLast
		let bitmapInfo = alphaInfo.rawValue | CGBitmapInfo.ByteOrder32Little.rawValue

		let imageWidth = Int(size.width * scale)
		let imageHeight = Int(size.height * scale)

		guard let bitmapContext = CGBitmapContextCreate(nil, imageWidth, imageHeight, 8, imageWidth * 4, colorSpace, bitmapInfo) else {
			fatalError("Error creating bitmap context")
		}

		renderingBlock(self, bitmapContext)

		return UIImage(
			CGImage: CGBitmapContextCreateImage(bitmapContext)!,


extension UIImage {
	internal func inflate(withSize size: CGSize, scale: CGFloat, opaque: Bool) -> UIImage {
		return self.processImageWithBitmapContext(
			withSize: size,
			scale: scale,
			opaque: opaque,
			renderingBlock: { _, _, _, imageDrawing in
				imageDrawing()
			}
		)
	}
