Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an easy way to get a CGImage from an NSImage #658

Closed
amgleitman opened this issue Nov 30, 2020 · 2 comments
Closed

Add an easy way to get a CGImage from an NSImage #658

amgleitman opened this issue Nov 30, 2020 · 2 comments
Labels
enhancement New feature or request Stale

Comments

@amgleitman
Copy link
Member

Proposal: Add an easy cross-platform way to get a CGImage from an NSImage

Summary

This is a minor syntactic change that would make working with NSImages easier.

Motivation

This is mostly for syntactic sugar purposes. For example, there are a number of places in react-native-macos that look something like this:

#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
  CGImageRef cgImage = image.CGImage;
#else // [TODO(macOS ISS#2323203)
  CGImageRef cgImage = [image CGImageForProposedRect:NULL context:NULL hints:NULL];
#endif // ]TODO(macOS ISS#2323203)

Ideally, it would be nice to just keep this the same line regardless of platform, whether through a category extension to NSImage or a couple of C-style functions in RCTUIKit.h, similar to what we have for various NSValues.

This has been added because it would have proven to be useful in a macOS implementation of react-native-svg. While simple to implement on the fly, this could prove useful for other modules that people may want to create, so it could probably find a better home in react-native-macos proper.

@ghost ghost added the Needs: Triage 🔍 label Nov 30, 2020
@chrisglein chrisglein added enhancement New feature or request and removed Needs: Triage 🔍 labels Jan 20, 2021
@github-actions
Copy link

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 19, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

2 participants