cgimage

Creating a large GIF with CGImageDestinationFinalize - running out of memory

对着背影说爱祢 提交于 2019-12-20 08:36:59
问题 I'm trying to fix a performance issue when creating GIFs with lots of frames. For example some GIFs could contain > 1200 frames. With my current code I run out of memory. I'm trying to figure out how to solve this; could this be done in batches? My first idea was if it was possible to append images together but I do not think there is a method for that or how GIFs are created by the ImageIO framework. It would be nice if there was a plural CGImageDestinationAddImages method but there isn't,

How to avoid malloc while using CGImageDestinationFinalize

一曲冷凌霜 提交于 2019-12-20 03:42:26
问题 I am trying to programmatically create GIF in iOS, using the following stack's question: Create and and export an animated gif via iOS? My code looks like this: // File Parameters const void *keys[] = { kCGImagePropertyGIFLoopCount }; const void *values[] = { (CFNumberRef) 0 }; CFDictionaryRef params = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL); const void *keys2[] = { kCGImagePropertyGIFDictionary }; const void *values2[] = { (CFDictionaryRef) params }; CFDictionaryRef

AVCAPTURE image orientation

青春壹個敷衍的年華 提交于 2019-12-20 02:34:11
问题 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 collection view above. I am having trouble with the correct orientation appearing in my preview above. Code is as follows: @IBOutlet weak var imagePreviews: UICollectionView! @IBOutlet weak var imgPreview: UIView! var session: AVCaptureSession? var

Swift: Cropping a Screenshot without TabBar and NavigationBar

ⅰ亾dé卋堺 提交于 2019-12-19 03:14:42
问题 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, false, scale); layer.renderInContext(UIGraphicsGetCurrentContext()) let screenshot = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() I'd like to crop it so that the tab bar is not included, and I tried using the following code:

How can I get the contents of an std::string into a CFData object?

孤者浪人 提交于 2019-12-18 07:07:29
问题 I've got a function that returns a std::string object. I'm working with Cocoa/CoreGraphics and I need a way to get the data from that string into a CFData object so that I can feed that into a CGDataProviderCreateWithCFData object to make a CGImage . The CreateCFData function wants a const UInt8* object ( UInt8 being a typedef for unsigned char ). The string represents the bytes from a decoded Base64 string (image data), so it appears to contain many null "characters" so the obvious casting

Turning an NSImage* into a CGImageRef?

我们两清 提交于 2019-12-17 22:25:45
问题 Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an IKImageView that seems to only want to add CGImages, but all I've got are NSImages. Currently, I'm using a private setImage:(NSImage*) method that I'd REALLY

NSImage to cv::Mat and vice versa

你。 提交于 2019-12-17 17:59:11
问题 while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom 回答1: Here's my outcome, which works pretty well. NSImage+OpenCV.h: // // NSImage+OpenCV.h // #import <AppKit/AppKit.h> @interface NSImage (NSImage_OpenCV) { } +(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat; -(id)initWithCVMat:(const cv::Mat&)cvMat; @property(nonatomic, readonly) cv::Mat CVMat; @property(nonatomic, readonly) cv::Mat

NSImage to cv::Mat and vice versa

南楼画角 提交于 2019-12-17 17:59:06
问题 while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom 回答1: Here's my outcome, which works pretty well. NSImage+OpenCV.h: // // NSImage+OpenCV.h // #import <AppKit/AppKit.h> @interface NSImage (NSImage_OpenCV) { } +(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat; -(id)initWithCVMat:(const cv::Mat&)cvMat; @property(nonatomic, readonly) cv::Mat CVMat; @property(nonatomic, readonly) cv::Mat

CGImage/UIImage lazily loading on UI thread causes stutter

南笙酒味 提交于 2019-12-17 06:26:10
问题 My program displays a horizontal scrolling surface tiled with UIImageViews from left to right. Code runs on the UI thread to ensure that newly-visible UIImageViews have a freshly loaded UIImage assigned to them. The loading happens on a background thread. Everything works almost fine, except there is a stutter as each image becomes visible. At first I thought my background worker was locking something in the UI thread. I spent a lot of time looking at it and eventually realized that the

Rotating a CGImage

蓝咒 提交于 2019-12-17 04:06:06
问题 I have a UIImage that I'm getting from a UIImagePickerController. When I receive the image from the - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info method I put it straight into a UIImageView for preview and give the user the option to either save or discard the image. When the user selects the save option the application get the png data for the image and saves it to it's documents directory. But what happens under one of the