Quartz 2D Stand for Graphics Port in SDK 10.10

Scenario:

I am editing some CGImage and, oddly enough, so far I have first created NSImage from these CGImage before drawing them. So I tried changing the code to draw a CGImage directly in NSGraphicsContext.currentContext().graphicsPort . As you can see, I use Swing here, but the same problem occurs for Objective-C, I suppose.

Looking at the documentation, I saw that graphicsPort would be deprecated at 10.10, but I could not find another way for the current CGContext from NSGraphicsContext and there is no way to create a CGContext from NSGraphicsContext .

Question:

Does anyone know what would be the right way to get context? If not - is there a way to make graphicsPort COpaquePointer , which is apparently an initialized NSPipe object, a CGContextRef ? Although using code that is already marked as deprecated will be quite unsatisfactory, I would consider it until there is a better solution.

+6
source share
1 answer

After you spent half an hour getting information about this, I realized that I just had to check the header file for NSGraphicsContext . It renders there a new property on NSGraphicsContext , which apparently has not yet been documented: CGContext . The header also notes that this should be used instead of graphicsPort .

+8
source

Source: https://habr.com/ru/post/973429/


All Articles