cgimage

Does CGImageRelease() free UIImage's memory?

筅森魡賤 提交于 2019-12-08 06:52:46
问题 I have the following code: UIImage *originalImage; CGImageRef cgImage = [originalImage CGImage]; I know that CGImage is a read-only property of UIImage class. Does the line CGImageRelease(cgImage) free originalImage 's memory? I'm tracing down a bug in my program and this line seems to be a hot candidate if I'm trying to access originalImage later. Thanks, Stefan 回答1: I've found the answer myself: Because the call CGImageRef img = [[UIImage imageNamed:@"pic.png"] CGImage]; does not contain

UIImage (CGImage) with memory mapped raw data

前提是你 提交于 2019-12-08 05:57:43
问题 Is there a way to store and load raw image data on disk in iOS in order to save time and memory on decompression and reduce app's dirty memory footprint? Paul Haddad has been hinting to something like this and I understand that this technique is used for efficient game texture loading with OpenGL. My use case if for user supplied full screen wallpaper, that is always displayed in the background. Currently I save it to PNG and load it during app startup. This wastes memory and CPU for

New CGIImage or CGImageRef from std::string using using base64

巧了我就是萌 提交于 2019-12-08 04:50:20
问题 everyone: I've been working on this for days. Here's a little bit of background. I'm sending an image to a server using protobuf. The image is directly from the camera, so it is not a jpeg nor a png. I found code to get the data from the UIImage using the CGImage to create a CGImageRef. See the following code: - (UIImage *)testProcessedImage:(UIImage *)processedImage { CGImageRef imageRef = processedImage.CGImage; NSData *data1 = (NSData *) CFBridgingRelease(CGDataProviderCopyData

Producing CCITT compressed TIFF from CGImage

怎甘沉沦 提交于 2019-12-08 03:06:20
问题 I have a CGImage (core graphics, C/C++). It's grayscale. Well, originally it was B/W, but the CGImage may be RGB. That shouldn't matter. I want to create a CCITT-Group 4 TIFF. I can create an LZW TIFF (grayscale or color) via creating a destination with the correct dictionary and adding the image in. No problem. However, there doesn't seem to be an equivalent kCGImagePropertyTIFFCompression value to represent CCITT-4. It should be 4, but that produces uncompressed. I have a manual CCITT

color balance on the iPhone

江枫思渺然 提交于 2019-12-08 02:04:30
问题 I am taking an image, loading it via the screen context, and changing it pixel by pixel. I have a number of different filters that I am applying to the images, but the last thing I need to do is shift the color balance (similar to Photoshop) to make the red more cyan. The code below shows how I am taking the image, getting the data, and going through the r/g/b values pixel by pixel: CGImageRef sourceImage = theImage.image.CGImage; CFDataRef theData; theData = CGDataProviderCopyData

Does CGImageRelease() free UIImage's memory?

喜欢而已 提交于 2019-12-07 08:00:33
I have the following code: UIImage *originalImage; CGImageRef cgImage = [originalImage CGImage]; I know that CGImage is a read-only property of UIImage class. Does the line CGImageRelease(cgImage) free originalImage 's memory? I'm tracing down a bug in my program and this line seems to be a hot candidate if I'm trying to access originalImage later. Thanks, Stefan I've found the answer myself: Because the call CGImageRef img = [[UIImage imageNamed:@"pic.png"] CGImage]; does not contain one of the words create , copy or alloc , I am not responsible for freeing this memory. 来源: https:/

Rotate and Crop UIImage

这一生的挚爱 提交于 2019-12-07 06:32:07
问题 Imagine I have an UIImage. I need to rotate and then crop it in the global coordinate system (not UIImage coordinate system). So the resulted image will be cropped and rotated. How can I do this? CGImageCreateWithImageInRect will crop image only in the image-relative coordinates. PS Answer in comments. You should use CIImage. 回答1: Maybe this can help //init CIImage *image = [CIImage imageWithCGImage:CGImageRef]; //rotation CIImage *rotatedImage = [image imageByApplyingTransform:someTransform]

IOS: Ambiguous Use of init(CGImage)

两盒软妹~` 提交于 2019-12-07 03:23:36
问题 I am trying to convert a CGImage into a CIImage ; however, it is not working. This line of code: let personciImage = CIImage(CGImage: imageView.image!.CGImage!) throws the following error Ambiguous use of 'init(CGImage)' I'm really confused as to what this error means. I need to do this conversion because CIDetector.featuresInImage() from the built in CoreImage framework requires a CIImage 回答1: I solved it on my own. It turns out, I was capitalizing CGImage wrong. The code should really read:

What does a correct call to CGImageCreate look like if the data provider for it uses an array created by the app?

风格不统一 提交于 2019-12-06 19:31:31
问题 I'm trying to create a bitmap in memory as part of a pattern function that a drawLayer:inContext: method (this method is part of the CALayer delegate protocol) will call. The pattern function looks similar to this: static const size_t kComponentsPerPixel = 4; static const size_t kBitsPerComponent = sizeof(unsigned char) * 8; NSInteger layerHeight = 160; NSInteger layerWidth = 160; CGContextSaveGState(context); CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); size_t bufferLength =

Trying to crop my UIImage to a 1:1 aspect ratio (square) but it keeps enlarging the image causing it to be blurry. Why?

江枫思渺然 提交于 2019-12-06 15:58:58
问题 Given a UIImage, I'm trying to make it into a square. Just chop some of the largest dimension off to make it 1:1 in aspect ratio. UIImage *pic = [UIImage imageNamed:@"pic"]; CGFloat originalWidth = pic.size.width; CGFloat originalHeight = pic.size.height; float smallestDimension = fminf(originalWidth, originalHeight); CGRect square = CGRectMake(0, 0, smallestDimension, smallestDimension); CGImageRef imageRef = CGImageCreateWithImageInRect([pic CGImage], square); UIImage *squareImage =