Questions tagged [uigraphicsimagerenderer]

34 questions
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…
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
7
votes
3 answers

How to take high-quality screenshot with UIGraphicsImageRenderer programmatically?

PROBLEM: After I take screenshot the image is blurry when check by zooming. The text inside image seems to be blurred when zoomed. I know this question have been raised many a times but none of them have desired solution. I already checked quite a…
Parvez Belim
  • 1,003
  • 13
  • 36
7
votes
0 answers

CGImageCreate: invalid image alphaInfo: kCGImageAlphaNone. It should be kCGImageAlphaNoneSkipLast

I'm trying to capture a UIVIew as an image, which I can then manipulate. I have code that works in Xcode 11.7/simulator (running iOS 13.7), but throws this error : CGImageCreate: invalid image alphaInfo: kCGImageAlphaNone. It should be…
3
votes
0 answers

UIGraphicsImageRenderer and UIGraphicsBeginImageContext: What is useful for UIImage.draw(in: CGRect)

I am newbie in swift and wanted to use UIImage.draw(in: CGRect) in my application to resize image. When I used UIGraphicsImageRenderer, it made some memory spikes rather than using UIGraphicsBeginImageContext. Since Apple discourages using…
3
votes
1 answer

Convert SwiftUI View to UIImage on iOS 14+

I can convert any SwiftUI View to a high resolution UIImage, using the code below. It works great... until... I try to use an image size larger than CGSize(width: 2730, height: 2730). If I increase the image size to CGSize(width: 2731, height: 2731)…
3
votes
1 answer

How to create an image of specific size from UIView

I'm working on iOS app which should enable users to create Instagram stories photos and export them to Instagram. Basically app like Unfold, Stellar, Chroma Stories... I've prepared UI where user can select from prepared templates and add to them…
Ondřej Korol
  • 594
  • 6
  • 19
2
votes
2 answers

SwiftUI ImageRenderer, render Path to image

I'm trying to make a simple drawing app in swift, iOS. So i've managed to draw using Path(). Now i want to save an image of what i've drawn. I have found on apple docs that ImageRenderer() is the thing to use nowadays. But i can't seem to make it…
J.Wennergren
  • 145
  • 14
2
votes
1 answer

UIGraphicsImageRenderer produces image with incorrect PPI

I'm trying to use UIGraphicsImageRenderer to fix the orientation of images before uploading to my web server, and the following code works but the images it produces have a higher PPI than I want: let imageRendererFormat =…
Logan Shire
  • 5,013
  • 4
  • 29
  • 37
2
votes
1 answer

How does it know? When UIColor sets fill and UIGraphicsImageRendererContext knows how to fill

I came across an example for using UIGraphicsImageRender to draw in a tutor on Medium. The example code is as follows: let renderer = UIGraphicsImageRenderer(size: CGSize(width: 20, height: 20)) let img = renderer.image { (ctx) in let size =…
2
votes
1 answer

How do I determine the maximum allowed size of an MTLTextureDescriptor

I am performing image manipulation using UIGraphicsImageRenderer(size: size, format: format). If the image is too large, it will fail with an assertion: failed assertion `MTLTextureDescriptor has width (15488) greater than the maximum allowed size…
Ric Santos
  • 15,419
  • 6
  • 50
  • 75
2
votes
0 answers

How to prevent UIView drawHierarchy from blocking or freezing an in-progress animation

My application renders a UIView to a UIImage using the below code: func asImage() -> UIImage { let renderer = UIGraphicsImageRenderer(bounds: bounds) return renderer.image { rendererContext in self.drawHierarchy(in: bounds,…
1
vote
2 answers

When converting SwiftUI view to image, it doesn't work as expected

My goal is to convert SwiftUI view to image. I am currently building it for iOS 15 here is the code that converts the view to image extension View { func snapshot() -> UIImage { let controller = UIHostingController(rootView: self) …
user4150758
  • 384
  • 4
  • 17
1
vote
0 answers

SwiftUI technique to update UINavigationBarAppearance.backgroundImage dynamically?

I am implementing a gradient background for the top navigation bar in SwiftUI using a standard NavigationView. For the gradient I am using a UIGraphicsImageRenderer to create a gradient image which I then assign to the backgroundImage of…
1
vote
0 answers

Resize UIView prior to taking a screenshot

I'm trying to convert an UIView to an UIImage to be saved to the photo album. Thus far, I have been able to get this, but the resultant image is based on the UIView's layout on screen. (eg: Portrait or Landscape) My goal is to have the same output…
app4g
  • 670
  • 4
  • 24
1
2 3