cgimageref

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 {

UIImage -> CGImageRef

眉间皱痕 提交于 2019-12-03 03:29:57
问题 I'm building an Iphone app that needs to convert a UIImage to a CGImageRef. I have no idea how to do this and would love some help. I have no background in working with images... :) 回答1: It is as simple as image.CGImage where image is a UIImage object. 回答2: CGImageRef cgImage = [someImage CGImage]; 回答3: write folowing to get CGImage from UIImage: Suppose u have an UIImage object ex imageObject then, CGImage imageRef = imageObject.CGImage 来源: https://stackoverflow.com/questions/6067307/uiimage

UIImage -> CGImageRef

痞子三分冷 提交于 2019-12-02 16:59:28
I'm building an Iphone app that needs to convert a UIImage to a CGImageRef. I have no idea how to do this and would love some help. I have no background in working with images... :) It is as simple as image.CGImage where image is a UIImage object. CGImageRef cgImage = [someImage CGImage]; Satish Azad write folowing to get CGImage from UIImage: Suppose u have an UIImage object ex imageObject then, CGImage imageRef = imageObject.CGImage 来源: https://stackoverflow.com/questions/6067307/uiimage-cgimageref

iOS 8.1 crash (EXC_BAD_ACCESS) : <Error>: ImageIO: CGImageReadGetBytesAtOffset : *** ERROR *** CGImageSource was created with data size:

╄→гoц情女王★ 提交于 2019-12-02 16:04:11
问题 Appreciate any help fixing a crash (EXC_BAD_ACCESS) in my iOS app. I am seeing this since updating my app to iOS 8, using latest available iOS 8.1.2. The same code worked fine in iOS 7.x. One of the views in my app is a UICollectionView . Every cell of the collection view shows an image, which is rendered dynamically and changes after every few minutes as new content become available. The top left of the cell also shows a text label/title for that cell of the collection view. To ensure the

Alpha Detection in Layer OK on Simulator, not iPhone

↘锁芯ラ 提交于 2019-12-01 10:22:50
问题 First, check out this very handy extension to CALayer from elsewhere on SO. It helps you determine if a point in a layer's contents-assigned CGImageRef is or isn't transparent. n.b.: There is no guarantee about a layer's contents being representable or responding as if it was a CGImageRef . (This can have implications for broader use of the extension referenced above, granted.) In my case, however, I know that the layers I'm testing have contents that were assigned a CGImageRef . (Hopefully

NSImage to cv::Mat and vice versa

↘锁芯ラ 提交于 2019-11-28 06:04:51
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 dom 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 CVGrayscaleMat; @end NSImage+OpenCV.mm: // // NSImage+OpenCV.mm // #import "NSImage+OpenCV.h" static void

How do I release a CGImageRef in iOS

天大地大妈咪最大 提交于 2019-11-26 18:34:58
I am writing this method to calculate the average R,G,B values of an image. The following method takes a UIImage as an input and returns an array containing the R,G,B values of the input image. I have one question though: How/Where do I properly release the CGImageRef? -(NSArray *)getAverageRGBValuesFromImage:(UIImage *)image { CGImageRef rawImageRef = [image CGImage]; //This function returns the raw pixel values const UInt8 *rawPixelData = CFDataGetBytePtr(CGDataProviderCopyData(CGImageGetDataProvider(rawImageRef))); NSUInteger imageHeight = CGImageGetHeight(rawImageRef); NSUInteger

How do I release a CGImageRef in iOS

和自甴很熟 提交于 2019-11-26 08:55:23
问题 I am writing this method to calculate the average R,G,B values of an image. The following method takes a UIImage as an input and returns an array containing the R,G,B values of the input image. I have one question though: How/Where do I properly release the CGImageRef? -(NSArray *)getAverageRGBValuesFromImage:(UIImage *)image { CGImageRef rawImageRef = [image CGImage]; //This function returns the raw pixel values const UInt8 *rawPixelData = CFDataGetBytePtr(CGDataProviderCopyData