cgimage

Losing image orientation while converting an image to CGImage

ぃ、小莉子 提交于 2019-11-29 11:55:27
问题 I'm facing an image orientation issue when cropping a square portion of an image out of a rectangular original image. When image is in landscape, it's fine. But when it is in portrait, it seems that the image orientation is not preserved, which result in an image with wrong orientation AND bad crop: func cropImage(cropRectangleCoordinates: CGRect) { let croppedImage = originalImage let finalCroppedImage : CGImageRef = CGImageCreateWithImageInRect(croppedImage.CGImage, cropRectangleCoordinates

takepicture() vs UIGetScreenImage()

馋奶兔 提交于 2019-11-29 10:52:00
I'm trying to build a QRCodeReader for a project our research group is working on for the iPhone. After much research I found the program called QuickMark . This program scans automatically for QRCodes. What it appears to do is load the UIImagePicker and read off data from the camera. I suspect it is using UIGetScreenImage and taking a screenshot from the camera and decoding it. Now I tried using the new takepicture() method from the 3.1 iPhone API but that seems not to be able to do what the above does which is take photos every second or so, silently. Now I had heard that UIGetScreenImage is

CGBitmapContextCreateImage - vm_copy failed - iPhone SDK

耗尽温柔 提交于 2019-11-29 09:45:09
I am having an issue using CGBitmapContextCreateImage in my iPhone app. I am using AV Foundation Framework to grab camera frames using this method: - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer,0); uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer); size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); size_t width =

iPhone - CGImageCreateWithImageInRect rotating some camera roll pictures

一曲冷凌霜 提交于 2019-11-29 04:40:16
问题 I am working on a pixelate application for iPhone. Because the pictures taken with the iPhone 4 camera are too big and therefore the application is working really slow when updating the pixelated picture, I am trying to create tiles of the picture first and just update the tiles not the hole picture. When building the tiles, it works for camera roll picture taken in landscape mode (2592 x 1936 pxl) and with low resolution pictures, but not with picture taken in portrait mode (1936 x 2592 pxl)

How exactly to make a CGImageRef from an image on disk

蹲街弑〆低调 提交于 2019-11-28 19:55:35
I've looked around everywhere to no avail. I'm doing some image loading in a thread and since UIKit is not thread safe I'm going to have to store the images as CGImageRefs but I can't figure out how to do this. I haven't played with any of the Quartz stuff before so it's confusing me. Basically I just need to load a JPG from the disk into a CGImageRef. Also for bonus points, is there anyway to load a GIF into a CGImageRef? Jerry Jones gcamp is more or less correct, you are pretty safe to use this on a background thread, but to answer your question, I believe the following would work.

Turning an NSImage* into a CGImageRef?

不问归期 提交于 2019-11-28 18:52:15
Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an IKImageView that seems to only want to add CGImages, but all I've got are NSImages. Currently, I'm using a private setImage:(NSImage*) method that I'd REALLY REALLY rather not be using... Found the following solution on this page : NSImage* someImage; // create the

iPhone: Changing CGImageAlphaInfo of CGImage

淺唱寂寞╮ 提交于 2019-11-28 17:16:01
I have a PNG image that has an unsupported bitmap graphics context pixel format. Whenever I attempt to resize the image, CGBitmapContextCreate() chokes on the unsupported format I receive the following error (error formatted for easy reading): CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaLast; 1344 bytes/row. The list of supported pixel formats definitely does not support this combination. It appears I need to redraw the image and move the alpha channel information to kCGImageAlphaPremultipliedFirst or

How do I create a mutable array of CGImageRefs?

大兔子大兔子 提交于 2019-11-28 09:35:08
问题 I want to keep a mutable collection of CGImageRefs. Do I need to wrap them in NSValue, and if so how do I wrap and unwrap them properly? Can I get away with using a C array? If so how do I construct it and how do I add elements to it later? Is it significantly more costly to use UIImages instead of CGImageRefs as the elements of the collection? 回答1: Getting the CGImageRef out of an UIImage via image.CGImage can be costly. From the documentation: If the image data has been purged because of

Pixel Array to UIImage in Swift

喜夏-厌秋 提交于 2019-11-28 08:34:47
I've been trying to figure out how to convert an array of rgb pixel data to a UIImage in Swift. I'm keeping the rgb data per pixel in a simple struct: public struct PixelData { var a: Int var r: Int var g: Int var b: Int } I've made my way to the following function, but the resulting image is incorrect: func imageFromARGB32Bitmap(pixels:[PixelData], width: Int, height: Int)-> UIImage { let rgbColorSpace = CGColorSpaceCreateDeviceRGB() let bitmapInfo:CGBitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedFirst.rawValue) let bitsPerComponent:Int = 8 let bitsPerPixel:Int = 32 assert(pixels

How can I get screenshot from all displays on MAC?

℡╲_俬逩灬. 提交于 2019-11-28 06:40:20
问题 I try to get the screenshot from all monitors connected with my MAC to one picture. I know, how I can do this if every monitor's screenshot will saved to different pictures, but it is not what I want. I found function CGGetDisplaysWithRect , but my solution don't work, because output picture is empty. I expect, that problem with function CGDisplayCreateImageForRect (*displays, rect), because first parameter must be CGDirectDisplayID type, but not CGDirectDisplayID*. But I can't find function,