func ImageCreate(img image.Image) ImageRef {
	data := extractImageData(img)

	memory := C.CFDataCreate(
		nil,
		(*C.UInt8)(unsafe.Pointer(&data.pixels[0])),
		C.CFIndex(len(data.pixels)),
	)

	provider := C.CGDataProviderCreateWithCFData(memory)

	cgimg := C.CGImageCreate(
		C.size_t(data.width),
		C.size_t(data.height),
		C.size_t(data.bpc),
		C.size_t(data.bpp),
		C.size_t(data.stride),
		data.colors,
		data.info,
		provider,
		nil,
		false,
		C.kCGRenderingIntentDefault,
	)

	C.CFRelease(provider)
	C.CFRelease(memory)
	C.CFRelease(data.colors)
	return ImageRef(unsafe.Pointer(cgimg))
}
// ImageCreate creates a new Core Graphics image object that represents the
// same content than the Go image passed as argument.
//
// The image content is copied by the funciton, it's the program's responsibility
// to free the resources allocated by the returned ImageRef with a call to
// CFRelease.
//
// The function supports any image types defined in the standard image package,
// but will panic if the program attempts to create a ImageRef from an
// unsupported value.
//
// https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGImage/
ImageCreate creates a new Core Graphics image object that represents the
same content than the Go image passed as argument.

The image content is copied by the funciton, it's the program's responsibility
to free the resources allocated by the returned ImageRef with a call to
CFRelease.

The function supports any image types defined in the standard image package,
but will panic if the program attempts to create a ImageRef from an
unsupported value.

developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGImage
// ImageCreate creates a new Core Graphics image object that represents the // same content than the Go image passed as argument . // // The image content is copied by the funciton it ' s the program ' s responsibility // to free the resources allocated by the returned ImageRef with a call to // CFRelease . // // The function supports any image types defined in the standard image package // but will panic if the program attempts to create a ImageRef from an // unsupported value . // // https : // developer . apple . com / library / mac / documentation / GraphicsImaging / Reference / CGImage /
func ImageCreate(img image.Image) ImageRef {
	data := extractImageData(img)
	memory := C.CFDataCreate(
		nil,
		(*C.UInt8)(unsafe.Pointer(&data.pixels[0])),
		C.CFIndex(len(data.pixels)),
	)
	provider := C.CGDataProviderCreateWithCFData(memory)
	cgimg := C.CGImageCreate(
		C.size_t(data.width),
		C.size_t(data.height),
		C.size_t(data.bpc),
		C.size_t(data.bpp),
		C.size_t(data.stride),
		data.colors,
		data.info,
		provider,
		nil,
		false,
		C.kCGRenderingIntentDefault,
	)
	C.CFRelease(provider)
	C.CFRelease(memory)
	C.CFRelease(data.colors)
	return ImageRef(unsafe.Pointer(cgimg))
}
func ImageCreate ( img image . Image ) ImageRef { data := extractImageData ( img ) memory := C . CFDataCreate ( nil , ( * C . UInt8 ) ( unsafe . Pointer ( & data . pixels [ 0 ] ) ) , C . CFIndex ( len ( data . pixels ) ) , ) provider := C . CGDataProviderCreateWithCFData ( memory ) cgimg := C . CGImageCreate ( C . size_t ( data . width ) , C . size_t ( data . height ) , C . size_t ( data . bpc ) , C . size_t ( data . bpp ) , C . size_t ( data . stride ) , data . colors , data . info , provider , nil , false , C . kCGRenderingIntentDefault , ) C . CFRelease ( provider ) C . CFRelease ( memory ) C . CFRelease ( data . colors ) return ImageRef ( unsafe . Pointer ( cgimg ) ) }
ImageCreate creates a new Core Graphics image object that represents the
same content than the Go image passed as argument.
ImageCreate creates a new Core Graphics image object that represents the same content than the Go image passed as argument .