Questions tagged [uigraphicscontext]

The UIGraphicsContext is not a class as you might think, but a set of functions that allows access to functions of CGContext. UIGraphicsContext is often used to create images or PDFs from code.

The UIGraphicsContext is the programmatic interface to the graphics contexts.

Since iOS 10 and tvOS 10 UIGraphicsRenderer and its subclasses facilitates the creation of documents via UIGraphicsRendererContext, which are based on Objective-C / Swift classes. The creation process is quite similar to working with functions from UIGraphicsContext so that these functions become less and less important.

314 questions
28
votes
4 answers

ios Sprite Kit screengrab?

I am trying to get a screen grab of a view that has a SKScene in it. The technique I am using is: UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, scale); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage…
Siegfoult
  • 1,844
  • 17
  • 19
19
votes
2 answers

swift UIGraphicsGetImageFromCurrentImageContext can't release memory

Swift Code When we get a screenshot of a UIView, we use this code usually: UIGraphicsBeginImageContextWithOptions(frame.size, false, scale) drawViewHierarchyInRect(bounds, afterScreenUpdates: true) var image:UIImage =…
GSLiPt
  • 201
  • 3
  • 6
18
votes
3 answers

iOS " current graphics context" - What is that

When I draw lines and shapes etc I get the " current graphics context" in iOS. What exactly though is " current graphics context" - I'm looking for the 30,000 foot description. Right now I just copy and paste UI code, not exactly sure what it's…
18
votes
9 answers

Rounding UIImage and adding a border

so I want to show some pictures as annotations on the map. In order to do that I need to add the image property of the MKAnnotationView. I'm using the regular images but I want them to be rounded and with a border. So I found a way to round UIImage…
Olexiy Burov
  • 1,007
  • 3
  • 11
  • 22
16
votes
3 answers

What is a graphic context? (iOS)

What exactly is a graphic context? When drawing with Core Graphic we get a reference to the context. When I look at the documentation it seems like it is an object or so that take care of the correct drawing whether it is for printing, device, pdf…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
11
votes
5 answers

Convert PDF to UIImage

func drawOnPDF(path: String) { // Get existing Pdf reference let pdf = CGPDFDocumentCreateWithURL(NSURL(fileURLWithPath: path)) // Get page count of pdf, so we can loop through pages and draw them accordingly let pageCount =…
Bhargav
  • 237
  • 1
  • 3
  • 10
11
votes
2 answers

How to take screen shot programmatically (Swift, SpriteKit)

I tried what ever was suggested but the output was a white,blank screenshot. Which leads me to assume that I haven't added anything to the view. Here's how I'm adding graphics to my view. The addChild method comes with the SpriteKit and it takes in…
htjohn
  • 422
  • 7
  • 21
10
votes
1 answer

IOS drawing a simple image turns out blurry using Xamarin C#

I'm developing in Xamarin and would like to draw a simple circle with the text "CIRCLE" inside it and display that image in a UIImageView. The problem is that the circle and text appear very blurry. I've read a bit about subpixels but I don't think…
Click Ahead
  • 2,782
  • 6
  • 35
  • 60
9
votes
2 answers

Rendering Emoji(String) to highest resolution image possible in iOS using extension/UIgraphicscontext

So it is known that apple's the images backing Emoji in unicode can be extracted at a resolution as high as 160x160 pixels. There is a tool available that can do this on OS X by pulling the data out of "apple color emoji" font here:…
Harrison
  • 319
  • 2
  • 14
9
votes
1 answer

Drawing performance UIGraphicsBeginImageContextWithOptions scale factor with Swift in Xcode for iOS app

I have a method for drawing, but drawing performance is greatly affected when adjusting the scale factor for UIGraphicsBeginImageContextWithOptions. When the scale is 1.0, everything works super fast, however, when the scale factor is either 0.0,…
user4806509
  • 2,925
  • 5
  • 37
  • 72
7
votes
1 answer

Understanding UIGraphicsGetCurrentContext()

I'm trying to understand Quartz and getting the context you have to draw on. If I have a function where I create a context, but then I call another function to some other drawing to the same context, do I need to pass the context from the first…
Crystal
  • 28,460
  • 62
  • 219
  • 393
7
votes
2 answers

How do I figure out pixel to point conversion on specific iPhone?

I'm trying to upload 256 x 256 images from my iOS app. I've resized an image to CGSize(width: 256, height: 256), but it gets uploaded as 768 x 768. This makes sense, because on my iPhone X, 1 point is 3 pixels. This isn't consistent though. On some…
David
  • 7,028
  • 10
  • 48
  • 95
7
votes
2 answers

Expensive renderInContext memory usage on main thread

I am using the follow code that is executed on the main thread to take a screenshot of an off screen (not a subview of self.view) view that then is displayed in an UIImageView. Everything works fine in terms of functionality, however because this…
user2284295
7
votes
0 answers

iOS, UIGraphics How to change only alpha channel when you drawing round rect to create brush with glow effect

I ma working on app that has brush tool. I need create brush like in Instagram. Currently I am using Shadow to create such glow effect. But I can't set such shadow effect. let startPoint = convertToOutput(firstPoint), endPoint =…
Victor.V
  • 177
  • 1
  • 9
7
votes
1 answer

FileManager says file doesn't exist when it does

I have a use case that requires a UIImage to be saved to the documents directory - then the UIImage needs to be converted into a PDF and saved to the documents directory. CODE TO CONVERT TO PDF var filePath = NSString(string:…
Brandon A
  • 8,153
  • 3
  • 42
  • 77
1
2 3
20 21