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...
I am wondering what the most efficient way is to make a CALayer with an image in it.
I know you can load a UIImage and then call [image CGImage] but is this the best way of going about it? As far as I can tell from Apple's documentation this is the only way you can do it.
...
Hi,
I am trying to convert an image into grayscale in the following way:
#define bytesPerPixel 4
#define bitsPerComponent 8
-(unsigned char*) getBytesForImage: (UIImage*)pImage
{
CGImageRef image = [pImage CGImage];
NSUInteger width = CGImageGetWidth(image);
NSUInteger height = CGImageGetHeight(image);
NSUInteger byte...
Hi,
in my Cocoa application, I load a .jpg file from disk, manipulate it. Now it needs to be written to disk as a .png file. How can you do that?
Thanks for your help!
...
I have a CGImageRef variable and a CGRect (so no pointers) and I need to add it to an NSDictionary. Like an NSArray, NSDictionary-s only accept pointers. How can you add an CGImageRef or an CGRect anyway?
...
Hi,
I have a CGImageRef that is lets say 35x35. I'm using it and a mask to create another image, but the mask is 50x50.
CGImageRef subImage = CGImageCreateWithImageInRect(imageRef, CGRectMake(x, y, 35, 35));
CGImageRef xMaskedImage = CGImageCreateWithMask(subImage, mask);
Apparently this stretches the subImage out to be 50x50, but w...
Hi,
I have a small image from a database and the image's average color need to be altered slightly.
It's a CGImageRef and I thought of creating a CGContext, drawing the image to this context, then subsequently changing the bitmap data somehow and finally rendering it.
But how can I alter the color information?
Thanks for your help!
...
How do I iterate on EACH PIXEL in a bitmap context? I found some source that seems to be attempting to do this but it is somehow flawed. Can someone tell me how to fix this code so that I can iterate on the RGBA of each pixel?
-(UIImage*)modifyPixels:(UIImage*)originalImage
{
NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageG...
Hi,
I created an app which creates an image by using CoreGraphics. The images appears on the screen when using the iPhone Simulator (OS 3.1 beta3) but not when I run the application on the device. What could be the cause of this?
The code snipped which extracts the image from the context and puts it in an image view looks like this:
...
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 coll...
Alright I am having a world of difficulty tracking down this memory leak. When running this script I do not see any memory leaking, but my objectalloc is climbing. Instruments points to CGBitmapContextCreateImage > create_bitmap_data_provider > malloc, this takes up 60% of my objectalloc.
This code is called several times with a NSTim...
Hi,
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 acces...
Hello all. 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 ...
Hi,
I googled for the memory issue associated with UIImage and came across many threads talking about the problem but no real help or solution.
I know when we use -imageNamed: the object is being cached so it's better to use initWithData:. When we use drawRect: and UIGraphicsGetImageFromCurrentImageContext(), does the image goes to cac...
Can anyone show me a clear example of how to use
CGImageRef CGImageCreate
(
size_t width,
size_t height,
size_t bitsPerComponent,
size_t bitsPerPixel,
size_t bytesPerRow,
CGColorSpaceRef colorspace,
CGBitmapInfo bitmapInfo,
CGDataProviderRef provider,
const CGFloat decode[],
bool shouldInterpolate,
CGCo...
I have this code:
CGDataProviderRef provider = CGDataProviderCreateWithFilename([myFile UTF8String]);
CGImageRef img = CGImageCreateWithJPEGDataProvider(provider, NULL, true, kCGRenderingIntentDefault);
Later I load that CGImageRef in a UIImage this way:
UIImage *uiImage = [[UIImage alloc] initWithCGImage:destImage];
I'd like to dr...
This appears to be the the classic method for scanning images from the iPhone. I have a thread that is dispatched from the main thread to go and scan for Codes. It essentially creates a new UIImage each time then removes it.
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
{
while (![thread isCancelled]) {
#ifdef DE...
Hi,
I want to display an image on the display.
Input images may be orientated. I can't go with CIImages as the images are raw images and it will take up huge amount of CPU and memory.
So i tried out with the CGImage, With thumbnail creation it works fine, but with image creation it doesn't provide the orientation less image.
NSDict...
I am using a color map lookup table in my indexed color space. When I use CGImageCreate to create the CGImage, then create a UIImage, I get an extra COLUMN of pixels in the first 32 bits (4 pixels) of every pixel row... which causes the image to shift right by 4 pixels. It looks like the color map is being written to the first 32 bits of...
When creating a custom sequential CGDataProvder to render a custom image format you specify the CGDataProviderSequentialCallbacks that should be used. While doing some optimization work to improve the speed of my sequential CGDataProvider I started to wonder about the thread safety of those callbacks.
Let's assume I have created a si...