uiimagepngrepresentation

UIImagePNGRepresentation and masked images

こ雲淡風輕ζ 提交于 2019-12-06 02:59:56
I created a masked image using a function form an iphone blog: UIImage *imgToSave = [self maskImage:[UIImage imageNamed:@"pic.jpg"] withMask:[UIImage imageNamed:@"sd-face-mask.png"]]; Looks good in a UIImageView UIImageView *imgView = [[UIImageView alloc] initWithImage:imgToSave]; imgView.center = CGPointMake(160.0f, 140.0f); [self.view addSubview:imgView]; UIImagePNGRepresentation to save to disk : [UIImagePNGRepresentation(imgToSave) writeToFile:[self findUniqueSavePath] atomically:YES]; UIImagePNGRepresentation returns NSData of an image that looks different. The output is inverse image

UIImagePickerControllerOriginalImage vs original asset data

China☆狼群 提交于 2019-12-05 02:57:51
In the app that I am developing, I am using an image that a user chooses from their photo albums. I need to upload a hi-res version of that photo to my server. I'm using imagePickerController and I've determined that I have 2 options use UIImage from UIImagePickerControllerOriginalImage get original asset by using UIImagePickerControllerReferenceURL and ALAssetsLibrary assetForURL (I don't like this because it prompts the user to use their current location, which I don't need) My question is... Is there any difference in the quality of the image if I use the first option vs the second? -(void

Any way to encode a PNG faster than UIImagePNGRepresentation?

允我心安 提交于 2019-12-04 10:23:24
问题 I'm generating a bunch of tiles for CATiledLayer . It takes about 11 seconds to generate 120 tiles at 256 x 256 with 4 levels of detail on an iPhone 4S. The image itself fits within 2048 x 2048. My bottleneck is UIImagePNGRepresentation . It takes about 0.10-0.15 seconds to generate every 256 x 256 image. I've tried generating multiple tiles on different background queue's, but this only cuts it down to about 9-10 seconds. I've also tried using the ImageIO framework with code like this: -

UIImagePNGRepresentation(UIImage()) returns nil

北慕城南 提交于 2019-12-04 00:36:05
问题 Why does UIImagePNGRepresentation(UIImage()) returns nil ? I'm trying to create a UIImage() in my test code just to assert that it was correctly passed around. My comparison method for two UIImage's uses the UIImagePNGRepresentation() , but for some reason, it is returning nil . Thank you. 回答1: UIImagePNGRepresentation() will return nil if the UIImage provided does not contain any data. From the UIKit Documentation: Return Value A data object containing the PNG data, or nil if there was a

Any way to encode a PNG faster than UIImagePNGRepresentation?

走远了吗. 提交于 2019-12-03 05:45:23
I'm generating a bunch of tiles for CATiledLayer . It takes about 11 seconds to generate 120 tiles at 256 x 256 with 4 levels of detail on an iPhone 4S. The image itself fits within 2048 x 2048. My bottleneck is UIImagePNGRepresentation . It takes about 0.10-0.15 seconds to generate every 256 x 256 image. I've tried generating multiple tiles on different background queue's, but this only cuts it down to about 9-10 seconds. I've also tried using the ImageIO framework with code like this: - (void)writeCGImage:(CGImageRef)image toURL:(NSURL*)url andOptions:(CFDictionaryRef) options {

UIImagePNGRepresentation … writeToFile is always landscape

不打扰是莪最后的温柔 提交于 2019-12-01 07:38:27
Each time I use the camera to take a photograph, then save it the image is always in landscape. This means the UIImageView in my Xib is the wrong way around. Its Portrait - which is what I want and expected. I can correct this by rotating the image 90 degrees but even then I can't disable the animation which shows the original landscape photo followed by the animated rotation itself. How can I ensure the UIImageView from the camera is actually in portrait mode when saved and not landscape and, how can I disable the animation during the CGAffineTranformationMakeRotation ?? I found this post to

UIImagePNGRepresentation … writeToFile is always landscape

走远了吗. 提交于 2019-12-01 05:29:04
问题 Each time I use the camera to take a photograph, then save it the image is always in landscape. This means the UIImageView in my Xib is the wrong way around. Its Portrait - which is what I want and expected. I can correct this by rotating the image 90 degrees but even then I can't disable the animation which shows the original landscape photo followed by the animated rotation itself. How can I ensure the UIImageView from the camera is actually in portrait mode when saved and not landscape and

UIImagePNGRepresentation(UIImage()) returns nil

北慕城南 提交于 2019-12-01 03:28:27
Why does UIImagePNGRepresentation(UIImage()) returns nil ? I'm trying to create a UIImage() in my test code just to assert that it was correctly passed around. My comparison method for two UIImage's uses the UIImagePNGRepresentation() , but for some reason, it is returning nil . Thank you. UIImagePNGRepresentation() will return nil if the UIImage provided does not contain any data. From the UIKit Documentation : Return Value A data object containing the PNG data, or nil if there was a problem generating the data. This function may return nil if the image has no data or if the underlying

Memory issue in using UIImagePNGRepresentation

此生再无相见时 提交于 2019-11-29 15:48:17
Hi Guys I found this module to be troublesome. I import more than 100 images from Photolibrary, save them in documents directory with a different name. As expected I had a memory issue in the unusual place. It seems UIImagePNGRepresenation is caching files. So when I run the below process for 300+ images, I see "Overall bytes" in the range of 3.00 GB and crashes due to Memory (tested in allocations tool). I have pasted the code below. Is there any alternative for this code -(void)something { NSData *data=nil; for (int i=0; i<numberOfImages; i++) { @autoreleasepool { UIImage *image=[UIImage

Convert UIImage to NSData without using UIImagePngrepresentation or UIImageJpegRepresentation

浪子不回头ぞ 提交于 2019-11-28 16:53:39
I Need to convert UIImage to NSData but without using UIImagePngRepresentation or UIImageJpegRepresentation , for images from photolib i can use assetlib method as mentioned here Using ALAssetsLibrary and ALAsset take out Image as NSData , but for captured image , assset url is not there hence in that case i need to convert UIImage directly to bytes with exif data , how can i accomplish this ? please help H Bastan, Based on your comment: ...I want to save the captured image return by device camera, through UIImagepicker delegate method in document directory... It looks like your real goal is