cgimage

Can I draw on an existing CGImage directly?

I want to draw on an existing image to achieve the accumulation effect. Currently, the only way I found is: UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); ... // draw the existing image // draw other things ... UIImage *color = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImage...

How to convert NSData to CGDataProviderRef on iphone sdk?

I am getting EXEC_BAD_ACCESS errors in a CGContextDrawImage call and trying to trace it back. I have a PNG image and running a UIImagePNGRepresentation o it gives me NSData instance. I need to convert this to CGImageRef instance, so I can run the CGImageCreateWithPNGDataProvider method with this CGImageRef. I tried two ways: 1) To cast...

How exactly to make a CGImageRef from an image on disk

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 int...

Draw part of CGImage

I have an application that draws images from a CGImage. The CImage itself is loaded using a CGImageSourceCreateImageAtIndex to create an image from a PNG file. This forms part of a sprite engine - there are multiple sprite images on a single PNG file, so each sprite has a CGRect defining where it is found on the CGImage. The problem i...

CGImageCreateWithImageInRect causing distortion

I'm using CGImageCreateWithImageInRect to do a magnifying effect, and it works beautifully, except when I get close to the edges of my view. In that case, clipping causes the image to be distorted. Right now I grab a 72x72 chunk of the view, apply a round mask to it, and then draw the masked image, and a circle on top. When the copied...

Multiplying RGBA with two CGImageRefs

I'd like to multiply r, g, b and a values of two CGImages, to use a single image as both a mask (in its alpha channel) and tint (in the rgb channels). I first tried simply: CGContextDrawImage(context, CGRectMake(0, 0, _w, _h), handle()); CGContextSetBlendMode(context, kCGBlendModeMultiply); CGContextDrawImage(context, CGRectMake(0, 0, o...

How can I get the contents of an std::string into a CFData object?

I've got a function that returns a std::string object. I'm working with Cocoa/CoreGraphics and I need a way to get the data from that string into a CFData object so that I can feed that into a CGDataProviderCreateWithCFData object to make a CGImage. The CreateCFData function wants a const UInt8* object (UInt8 being a typedef for unsign...

Buffere write becomes slow after CGBitmapContextCreate

I have code something like this... CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate(pixelArray, width, height, 8, 4 * width, colorSpace, kCGImageAlphaNoneSkipLast); CGImageRef createdImage = CGBitmapContextCreateImage (ctx); uiImage = [[UIImage imageWithCGImage:createdImage] retain];...

PicHandle to CGImageRef

This project is a generic C++ plugin with core-graphics support. I am unable to convert a PicHandle to CGImageRef successfully. Saving off image from CFDataRef results in a bad image. if(pic) { Handle thePictureFileHandle; thePictureFileHandle = NewHandleClear(512); HandAndHand((Handle)pic,thePictureFileHandle); d...

how to save an image with text on another image?

Hi All, I any one have idea about taking snapshot from iphone application through coding. means. I am developing an iphone application where there will be two images dynamically comes. There will be a text view with clear color on those particular images. users will be able to write any text on the images and click save button. Then t...

Capturing a view from iphone through coding

Hi All, In my iPhone application, i am using the following code to get a snap shot from the iphone application. -(UIImage *)captureView:(UIView *)view { CGRect screenRect = [view bounds]; UIGraphicsBeginImageContext(screenRect.size); CGContextRef ctx = UIGraphicsGetCurrentContext(); [[UIColor clearColor] set]; CGContextFillRect(c...

iPad (very) simple drawing

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...

Help please with CGBitmapContext and 16 bit images

I'd LOVE to know what I'm doing wrong here. I'm a bit of a newbie with CGImageRefs so any advice would help. I'm trying to create a bitmap image that has as it's pixel values a weighted sum of the pixels from another bitmap, and both bitmaps are 16bits per channel. For some reason I had no trouble getting this to work with 8bit images b...

Converting CVImageBufferRef to PNG

Hi, I want to write all frames to disk using QTKit.framework for camera input. But all the images I get are half transparent and without some colors, maybe colorspace problem? ;( They seem good in the preview View but when I write them "something" happens. I wonder what it that. -(void)savePNGImage:(CGImageRef)imageRef path:(NSString *)...

How to grab an image of an offscreen NSWindow?

I'm trying to get an image of an offscreen window to use in a CALayer-based animation, but no matter which method I try I cannot get an image out the other side. Here is the code I've been using on a custom NSWindow subclass in my project: CGImageRef windowImage = CGWindowListCreateImage(CGRectNull, ...

saving images in lower quality(256, 16, 4, 2 colors) - cocoa

Hi. I am trying to work with images in Cocoa - open images and manipulate with them. I take ImageApp as example . All work fine, but I need to save images in lower quality -(8, 4, 2, 1 bits per pixel - 256, 16, 4, 2 colors respectively). According to documentation, the "lowest" pixel format is Gray 8 bpp, 8 bpc,kCGImageAlphaNone and i...