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
4
votes
1 answer

Display NSImage from NSData

My target is to display an image in a view. Considering I've an: IBOutlet NSImageView *image for display my image NSData *imageData for readig the image file NSImage *imageView In imageData is stored the image (I've used initWithContentsOfFile…
Matteo
  • 41
  • 1
  • 3
4
votes
1 answer

AVCAPTURE image orientation

I have a view controller which allows a user to take a picture. I am setting the avcapture bounds to be the bounds of a view on screen. Above this view I have a collection view. So users can capture multiple pictures, they are then added to the…
user2363025
  • 6,365
  • 19
  • 48
  • 89
4
votes
1 answer

UIImage size doubled when converted to CGImage?

I am trying to crop part of an image taken with the iPhone's camera via the cropping(to:) method on a CGImage but I am encountering a weird phenomenon where my UIImage's dimensions are doubled when converted with .cgImage which, obviously, prevents…
Herakleis
  • 513
  • 5
  • 21
4
votes
0 answers

Swift: CGImage.masking returns nil

Why does CGImage.masking method may return nil? I can't find any documentation on this. My code for some images returns nil: extension UIImage { func maskedImage(mask:(UIImage))->UIImage{ let croppingRect = CGRect(x:…
peetonn
  • 2,942
  • 4
  • 32
  • 49
4
votes
2 answers

Drawing histogram of CGImage in Swift 3

I have a problem with vImageHistogramCalculation_ARGB8888 method while trying to convert library from Swift 2 to Swift 3 version. The problem is that the method accepts "histogram" argument only as UnsafeMutablePointer?>…
Mr. A
  • 704
  • 1
  • 7
  • 16
4
votes
1 answer

How to grab an image of an offscreen NSWindow?

I'm trying to get an image of an offscreen window to use in a CALayer-based animation, but no matter which method I try I cannot get an image out the other side. Here is the code I've been using on a custom NSWindow subclass in my…
Tony Arnold
  • 2,738
  • 1
  • 23
  • 34
4
votes
3 answers

Converting CVImageBufferRef to PNG

I want to write all frames to disk using QTKit.framework for camera input. But all the images I get are half transparent and without some colors, maybe colorspace problem? ;( They seem good in the preview View but when I write them "something"…
nacho4d
  • 43,720
  • 45
  • 157
  • 240
4
votes
1 answer

Convert CGImage to NSImage Swift

I am trying to display a CGImage in a NSImageView box and I am having trouble converting the CGImage to a NSImage. How should I approach this situation ? Thank you!
ch_studend
  • 91
  • 2
  • 10
4
votes
1 answer

Swift playground - cannot convert a filtered UIImage to a CGImage

In a Swift playground, I am loading a JPEG, converting it to a UIImage and filtering it to monochrome. I then convert the resulting filtered image to a UIImage. The input and the filtered images display correctly. I then convert both images to a…
Simon Youens
  • 177
  • 1
  • 13
4
votes
3 answers

Creating an NSImage from bitmap data

Ok, it appears that the I'm creating a PDFDocument where pixelWidth is incorrect in the images that I created. So the question becomes: How do I get the correct resolution into the image? I start with bitmap data from a scanner. I'm doing…
Brian Postow
  • 11,709
  • 17
  • 81
  • 125
4
votes
1 answer

Create a gif with UIImages

I am referring to this post . I am trying to make a gif file with the images created by screenshot. I am using a timer to create the snapshot of the screen,so that I get required amount of frames that could be used to create a gif. I take snaphots…
Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
4
votes
1 answer

Getting the raw RGB buffer from an CGImageRef

I am trying to get a pointer access directly to the underlying RGB buffer of a CGImageRef. My first attempt is as follow: CGImageRef image = [...]; CFDataRef rawData = CGDataProviderCopyData(CGImageGetDataProvider(image)); const UInt8 * buf =…
malat
  • 12,152
  • 13
  • 89
  • 158
4
votes
1 answer

Dictionary now gives error 'not convertible to BooleanLiteralConvertible' since updating to Swift 1.2

I'm was just getting my head around Swift - then came Swift 1.2 (breaking my working code)! I have a function based on the code sample from NSHipster - CGImageSourceCreateThumbnailAtIndex. My previously working code is: import ImageIO func…
So Over It
  • 3,668
  • 3
  • 35
  • 46
4
votes
1 answer

How to create CGImageRef from NSData string data (NOT UIImage)

How does one create a new CGImageRef without a UIImage? I can't use image.CGImage I am receiving a base64 encoded image as a std::string from a server process. The first part of the code below simulates receiving the encoded string. - (UIImage…
Patricia
  • 5,019
  • 14
  • 72
  • 152
4
votes
1 answer

EXC_BAD_ACCESS error with CGImageRef

I have a function: - (UIImage *) resizeImage:(UIImage *)image width:(CGFloat)resizedWidth height:(CGFloat)resizedHeight shouldCrop:(BOOL)crop { CGImageRef imageRef = [image CGImage]; CGColorSpaceRef colorSpace =…
Halpo
  • 2,982
  • 3
  • 25
  • 54