cgimage

Create a gif with UIImages

折月煮酒 提交于 2019-12-04 12:46:01
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 every 0.1 seconds (I will later end this timer after 3 seconds). Here is my code to take snapshots of my UIView: -(void)recordScreen{ self.timer= [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(takeSnapShot) userInfo:nil repeats:YES]; } -(void)takeSnapShot{ //capture the screenshot of the uiimageview and save it in camera

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

醉酒当歌 提交于 2019-12-04 09:09:52
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 processImage(jpgImagePath: String, thumbSize: CGSize) { if let path = NSBundle.mainBundle().pathForResource(jpgImagePath, ofType: "") { if let imageURL = NSURL(fileURLWithPath: path) { if let imageSource = CGImageSourceCreateWithURL(imageURL, nil) { let maxSize = max(thumbSize.width, thumbSize.height) / 2.0 let options = [

UIImage looses its orientation while converting it into CIImage, then into CGImage and back to UIImage

倖福魔咒の 提交于 2019-12-04 07:00:00
问题 I know there are tons of questions like this but their solutions don't work for me. NOTE: The image is downloaded from the Internet. It isn't taken from iPhone 's camera. I have a UIImage . To do some image processing operations I use Metal and present the image in a MTKView . So, I convert the image into a CIImage . After doing all the modifications to the image I convert it back into CGImage and then into UIImage and save it. As a result the saved image's orientation is wrong. I'm not sure

How to determine and interpret the pixel format of a CGImage

我是研究僧i 提交于 2019-12-04 04:49:14
I'm loading this (very small) image using: UIImage* image = [UIImage named:@"someFile.png"]; The image is 4x1 and it contains a red, green, blue and white pixel from left to right, in that order. Next, I get the pixel data out of the underlying CGImage: NSData* data = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage)); Now, for some reason, the pixel data is laid out differently depending on the iOS device. When I run the app in the simulator or on my iPhone 4, the pixel data looks like this: (255,0,0),(0,255,0),(0,0,255),(255,255,255) So, the pixels are 3 bytes per pixel,

Mixing Images and Video using AVFoundation

房东的猫 提交于 2019-12-03 14:11:33
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 image in CALayer using AVVideoCompositionCoreAnimationTool AVFoundation Tutorial: Adding Overlays and Animations to Videos and a few other SO links Now these have proved to be pretty useful at times, but my problem is that I'm not creating a static watermark or an overlay exactly I want to put in images between parts of the video. So far I've managed

Swift accessing EXIF Dictionary

 ̄綄美尐妖づ 提交于 2019-12-03 09:55:53
问题 Info: Using Swift and the CGImageSourceCreateWithURL function. I am attempting to load a file from a URL and then edit a dictionary which has all the data from that particular photo. This is the code from the .swift file. let url = NSURL(string: "http://jwphotographic.co.uk/Images/1.jpg") let imageSource = CGImageSourceCreateWithURL(url, nil) let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary println(imageProperties) //this is an example let aperture =

Why is my image's Bytes per Row more than its Bytes per Pixel times its Width?

时光毁灭记忆、已成空白 提交于 2019-12-03 09:17:26
问题 I'm converting images to a MOV file, and had an interesting thing happen to me. I logged my bits per color component, bits per pixel, and bytes per row. Here's my code: NSLog(@"Image width: %d, Height: %d", CGImageGetWidth(image), CGImageGetHeight(image)); NSLog(@"BPC: %d \ BPP: %d \ ByPR: %d", CGImageGetBitsPerComponent(image), CGImageGetBitsPerPixel(image), CGImageGetBytesPerRow(image)); Here's my output: Image Width: 300, Height: 300 (everything's as expected) BPC: 8 (8 bits per color...so

iPad (very) simple drawing

走远了吗. 提交于 2019-12-03 04:40:35
问题 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. - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docsPath = [paths objectAtIndex:0]; NSString *savePath =

What is the most memory-efficient way of downscaling images on iOS?

旧巷老猫 提交于 2019-12-03 04:16:33
问题 In background thread, my application needs to read images from disk, downscale them to the size of screen (1024x768 or 2048x1536) and save them back to disk. Original images are mostly from the Camera Roll but some of them may have larger sizes (e.g. 3000x3000). Later, in a different thread, these images will frequently get downscaled to different sizes around 500x500 and saved to the disk again. This leads me to wonder: what is the most efficient way to do this in iOS, performance and memory

Why is my image's Bytes per Row more than its Bytes per Pixel times its Width?

这一生的挚爱 提交于 2019-12-02 23:29:42
I'm converting images to a MOV file, and had an interesting thing happen to me. I logged my bits per color component, bits per pixel, and bytes per row. Here's my code: NSLog(@"Image width: %d, Height: %d", CGImageGetWidth(image), CGImageGetHeight(image)); NSLog(@"BPC: %d \ BPP: %d \ ByPR: %d", CGImageGetBitsPerComponent(image), CGImageGetBitsPerPixel(image), CGImageGetBytesPerRow(image)); Here's my output: Image Width: 300, Height: 300 (everything's as expected) BPC: 8 (8 bits per color...so far so good) BPP: 32 (32 = 4 components ARGB * 8 bits per color...got it) ByPR:1216 (300 px per row *