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

	provider := C.CGDataProviderCreateWithData(
		nil,
		unsafe.Pointer(&data.pixels[0]),
		C.size_t(len(data.pixels)),
		nil,
	)

	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(data.colors)
	return ImageRef(unsafe.Pointer(cgimg))
}
// ImageCreateNoCopy creates a new Core Graphics image object that represents the
// same content than the Go image passed as argument.
//
// The image content is shared between the Go and Core Graphics images, so the
// program must ensure that the image.Image value it passed to the function is
// referenced and unmodified for as long as the returned ImageRef is in use.
// 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/
ImageCreateNoCopy creates a new Core Graphics image object that represents the
same content than the Go image passed as argument.

The image content is shared between the Go and Core Graphics images, so the
program must ensure that the image.Image value it passed to the function is
referenced and unmodified for as long as the returned ImageRef is in use.
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
// ImageCreateNoCopy creates a new Core Graphics image object that represents the // same content than the Go image passed as argument . // // The image content is shared between the Go and Core Graphics images so the // program must ensure that the image . Image value it passed to the function is // referenced and unmodified for as long as the returned ImageRef is in use . // 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 ImageCreateNoCopy(img image.Image) ImageRef {
	data := extractImageData(img)
	provider := C.CGDataProviderCreateWithData(
		nil,
		unsafe.Pointer(&data.pixels[0]),
		C.size_t(len(data.pixels)),
		nil,
	)
	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(data.colors)
	return ImageRef(unsafe.Pointer(cgimg))
}
func ImageCreateNoCopy ( img image . Image ) ImageRef { data := extractImageData ( img ) provider := C . CGDataProviderCreateWithData ( nil , unsafe . Pointer ( & data . pixels [ 0 ] ) , C . size_t ( len ( data . pixels ) ) , nil , ) 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 ( data . colors ) return ImageRef ( unsafe . Pointer ( cgimg ) ) }
ImageCreateNoCopy creates a new Core Graphics image object that represents the
same content than the Go image passed as argument.
ImageCreateNoCopy creates a new Core Graphics image object that represents the same content than the Go image passed as argument .