cgimage

Add CGImage to CGImageDestination at specific index

爱⌒轻易说出口 提交于 2019-12-11 18:11:40
问题 Is there an option to add CGImage to specific index inside CGImageDestination ? We tried using CGImageDestinationAddImage but it adds images at a incremental order. We are creating some expensive CGImages where we need to add them in multiple indexes inside the destination. We thought about adding them to all needed "indexes" at once, saving the recreation. generator.generateCGImagesAsynchronously(forTimes: <BigArrayOfTimes>, completionHandler: { (requestedTime, expensiveCgImage, actualTime,

UIGraphicsBeginImageContext created image stays in memory forever

假如想象 提交于 2019-12-11 14:52:31
问题 I'm creating many colour variations of an image using Core Graphics. I need to create about 320 in total but gradually, the memory usage of the app keeps increasing until it crashes. From Instruments, I see that more CGImage objects are being created and stay alive. I want to release them because I store the images to the cache directory in PNG format. I have searched through all other solutions I could find without success. Any help is appreciated. Thanks. Here's the main part: +(UIImage *

iphone 4s - UIImage CGImage image dimensions

早过忘川 提交于 2019-12-11 05:08:38
问题 I have a crash which only occurs on 4S (not on 3GS). I am doubting its because of @2x. Basically I get raw bytes of image and manipulate. Here's the question I have. I load a image as mentioned in the sample code below. At the end, uiWidth should be 2000 and cgwidth should be 2000. Correct? (Would it still be true if image is loaded from camera rolls? Or its autoscaling and uiWidth will be 4000?) //test.jpg is 2000x 1500 pixels. NSString *fileName = [[NSBundle mainBundle] pathForResource:@

Set alpha of some pixels to zero

為{幸葍}努か 提交于 2019-12-11 04:53:18
问题 Let's say I have 2 images, one on top of the other. I want to set a portion of the top image's pixel's alpha values to zero so I get this effect illustrated below: The brown is the top image, and the blue water is the bottom image. Ultimately what I'm going to do is have the alpha channel of the top image's pixels change to zero as the user touches the iPad screen so they can essentially draw with their fingertip and have the blue water image appear. I have a function that can examine the

How create UIImage from bytes?

我是研究僧i 提交于 2019-12-11 04:06:14
问题 I need in UIImage created from my colors (for example, i need in image 1x1 pixel with black color). I've got array: unsigned char *color[] = {0, 0, 0, 1}; How can i create UIImage from this array ? I've try unsigned char *bytes[4] = {0,0,0,1}; NSData *data = [NSData dataWithBytes:bytes length:4]; UIImage *img = [UIImage imageWithData:data]; but this method has no result... 回答1: You'll want to create a bitmap context (using CGBitmapContextCreate()), and draw into that. This requires using

CGImageRef cg = [[UIImage imageNamed: Path] CGImage]; Requires a CGImageRelease(cg)'?

核能气质少年 提交于 2019-12-11 02:29:50
问题 I am trying to read the ARGB pixels from a an image asset in iOS. For that, I need a CGImageRef I can use to get its CGDataProvider . My question is, if I create a CGImageRef using: CGImageRef cg = [[UIImage imageNamed: Path] CGImage]; Will I eventually need to call CGImageRelease(cg) ? If I don't call CGImageRelease , will I have a memory leak? Another issue I am having is that reading the same file for a second time returns an empty image, which I suspect might be because I didn't call

what is resolution of photo taken by iPhone 4 camera?

我只是一个虾纸丫 提交于 2019-12-10 21:16:18
问题 In specs, iPhone 4 screen resolution & pixel density * iPhone 4 has a screen resolution of 960×640 pixels, which is twice that of the prior iPhone models As we know, when we code like this, CGImageRef screenImage = UIGetScreenImage(); CGRect fullRect = [[UIScreen mainScreen] applicationFrame]; CGImageRef saveCGImage = CGImageCreateWithImageInRect(screenImage, fullRect); the saveCGImage will have size (320,480), my question is how about iPhone 4 ? Is that (640,960) ? Another question is about

Working with images (CGImage), exif data, and file icons

烈酒焚心 提交于 2019-12-10 10:17:05
问题 What I am trying to do (under 10.6).... I have an image (jpeg) that includes an icon in the image file (that is you see an icon based on the image in the file, as opposed to a generic jpeg icon in file open dialogs in a program). I wish to edit the exif metadata, save it back to the image in a new file. Ideally I would like to save this back to an exact copy of the file (i.e. preserving any custom embedded icons created etc.), however, in my hands the icon is lost. My code (some bits removed

CGImageRelease in Swift

浪尽此生 提交于 2019-12-10 00:44:36
问题 In Objc I use CGImageRelease method after the treatment of an image. But in Swift this method is not available. On the Apple documentation after Retaining and Releasing Images there is a 2 Objective-C symbols hidden My question is, why is there no more CGImageRelease in Swift ? And have we to call another method to replace it ? Thanks ! 回答1: CGImage is now managed by ARC. CGImageRelease() is no longer required on it. You can know this by looking in CGImage.h and noting that it includes the

Save CIImage, by converting to CGImage, throws an error

我只是一个虾纸丫 提交于 2019-12-08 09:46:10
问题 I have an image I'm grabbing from AVFoundation: [stillImage captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) { NSLog(@"image capture"); NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]; UIImage *image = [[UIImage alloc] initWithData:imageData]; I'm then cropping this image by first converting to a CIImage: beginImage = [CIImage imageWithCVPixelBuffer