core-foundation-rs icon indicating copy to clipboard operation
core-foundation-rs copied to clipboard

Change argument type from `&CGImage` to `&CGImageRef`

Open gyk opened this issue 4 years ago • 0 comments

Some methods of CGContext accept an argument image: &CGImage. CGImage will automatically call CGImageRelease when it is dropped.

The problem is, sometimes we don't actually own the CGImage. For example, I try to obtain a sys::CGImageRef from an NSImage using CGImageForProposedRect, and draw it on some CGBitmapContext with CGContext::draw_image. As the documentation says, the caller should not release the returned value. So it should be only possible to convert the raw pointer to a&CGImageRef rather than a CGImage. Changing the argument type to &CGImageRef will make the interface more flexible.

gyk avatar Oct 14 '21 11:10 gyk