Questions tagged [cgimage]

CGImage represents a drawable image object in Core Graphics (the low-level procedural drawing API for iOS and Mac OS X).

563 questions
7
votes
1 answer

Color distortion in CGImageCreate

I am trying to build a image capture for my iOS app, but I keep getting color distortion on my CGImage result. Here is the camera preview, right colors. Cola is red, all is well. When I run my snapshot code, I get this : Cola is blue... where did…
Nils Munch
  • 8,805
  • 11
  • 51
  • 103
7
votes
1 answer

ScreenCaptureKit/CVPixelBuffer format yields unexpected results

I have a project where I use ScreenCaptureKit. For various reasons out of the scope of the question, the format that I configure ScreenCaptureKit to use is kCVPixelFormatType_32BGRA -- I need the raw BGRA data, which gets manipulated later on. When…
jnpdx
  • 45,847
  • 6
  • 64
  • 94
7
votes
1 answer

How to save CGImage to Data in Swift?

This code type checks and compiles but then crashes. How do I save a CGImage to Data so that I can read it in again later. let cgi: CGImage? = ... var mData = Data() let imageDest = CGImageDestinationCreateWithData(mData as! CFMutableData, …
Rob N
  • 15,024
  • 17
  • 92
  • 165
7
votes
1 answer

swift - CGImage to CVPixelBuffer

How can I convert a CGImage to a CVPixelBuffer in swift? I'm aware of a number of questions trying to do the opposite, and of some objective C answers, like this one but I could not get them to work in swift. Here's the closest I've got: func…
Guig
  • 9,891
  • 7
  • 64
  • 126
7
votes
1 answer

Unable to edit screenshots, performChanges block fails

I'm developing an app that allows users to edit photos using PhotoKit. I was previously saving the edited photo to disk as a JPEG. I would like to avoid converting to JPEG and have implemented the modifications in order to do that. It works great…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
7
votes
1 answer

CGContextClear Warning

I'm having an issue with iOS while using CGImageDestinationFinalize. I'll call CGImageDestinationFinalize on a CGImageDestinationRef and I'll get the following warning Error: The function `CGContextClear' is obsolete and will be removed in an…
Zachary Orr
  • 1,724
  • 1
  • 15
  • 25
6
votes
1 answer

How to crop and flip CVPixelBuffer and return CVPixelBuffer?

I am making an swift video app. In my app, I need to crop and horizontally flip CVPixelBuffer and return result which type is also CVPixelBuffer. I tried few things. First, I used 'CVPixelBufferCreateWithBytes' func resizePixelBuffer(_…
HB.K
  • 167
  • 2
  • 12
6
votes
1 answer

IOS: Ambiguous Use of init(CGImage)

I am trying to convert a CGImage into a CIImage; however, it is not working. This line of code: let personciImage = CIImage(CGImage: imageView.image!.CGImage!) throws the following error Ambiguous use of 'init(CGImage)' I'm really confused as to…
James Dorfman
  • 1,740
  • 6
  • 18
  • 36
6
votes
2 answers

iPad (very) simple drawing

I'm trying to implement a very simple drawing view in my app. This is only a small part of my app but it's turning into a real hassle. This is what I have so far, but all it's displaying right now is morse code like dots and lines. -…
Brodie
  • 3,526
  • 8
  • 42
  • 61
6
votes
2 answers

How exactly to make a CGImageRef from an image on disk

I've looked around everywhere to no avail. I'm doing some image loading in a thread and since UIKit is not thread safe I'm going to have to store the images as CGImageRefs but I can't figure out how to do this. I haven't played with any of the…
Alexander
  • 409
  • 1
  • 4
  • 14
6
votes
5 answers

Swift: Cropping a Screenshot without TabBar and NavigationBar

I have a screenshot of the entire screen, screenshot, generated using the following: let layer = UIApplication.sharedApplication().keyWindow!.layer let scale = UIScreen.mainScreen().scale UIGraphicsBeginImageContextWithOptions(layer.frame.size,…
Randoms
  • 2,110
  • 2
  • 20
  • 31
6
votes
1 answer

Image becomes blurry when painting a Image from GraphicContext?

I created a ViewController with a UIImageView in the storyboard. The ImageView is set to Aspect Fit and gets a yellow background color. Here is the photo I used for the test. When I run my app the image appears is shown below: There is no problem.…
Michael
  • 32,527
  • 49
  • 210
  • 370
6
votes
2 answers

Converting CIImage to CGImage too slow

I need to convert a CIImage to a CGImage. This is the code I am currently using: CGImageRef img = [myContext createCGImage:ciImage fromRect:[ciImage extent]]; But his line of code is very slow for images with a regular size. Much to slow that I can…
Laurens
  • 85
  • 1
  • 7
6
votes
1 answer

Mixing Images and Video using AVFoundation

I'm trying to splice in images into a pre-existing video to create a new video file using AVFoundation on Mac. So far I've read the Apple documentation example, ASSETWriterInput for making Video from UIImages on Iphone Issues Mix video with static…
Tom Haygarth
  • 111
  • 1
  • 9
6
votes
2 answers

IOS: Masking an image keeping retina scale factor in account

I want to mask an image by passing another image as mask. I am able to mask the image but the resulting image doesn't look good. It is jagged at borders. I guess the problem is related to retina graphics. The scale property for the two images are…
Gaurav Singh
  • 1,897
  • 14
  • 22