I tried a ton of different options and tricks to get UIImage to properly build from CIImage. But every time I create CIImage, its colors seem to be inverted.
The most recent code I have is:
NSURL *url = [[NSBundle mainBundle] URLForResource:@"C4Sky" withExtension:@"png"];
CIImage *c = [CIImage imageWithContentsOfURL:url];
UIImage *i = [UIImage imageWithCIImage:c];
UIImageView *uiiv = [[UIImageView alloc] initWithImage:i];
[self.canvas addSubview:uiiv];
Which creates the following image:

However, creating the image as follows:
UIImage *i = [UIImage imageNamed:@"C4Sky"];
UIImageView *uiiv = [[UIImageView alloc] initWithImage:i];
[self.canvas addSubview:uiiv];
... creates the following image:

I tried many different ways to create CIImage.
Is this because the pixel format in iOS for CIImage is ARGB? (This seems to be the only format you can use on iOS6 right now)
, , CIImage ?
git, , ( ). 6 , 5 :
https://github.com/C4Code/CIImageTest
, :
-(void)test6 {
UIImage *img = [UIImage imageNamed:@"C4Sky"];
CGContextRef bitmapContext = NULL;
void * bitmapData;
int bitmapByteCount;
int bitmapBytesPerRow;
CGSize size = img.size;
bitmapBytesPerRow = (size.width * 4);
bitmapByteCount = (bitmapBytesPerRow * size.height);
bitmapData = malloc( bitmapByteCount );
bitmapContext = CGBitmapContextCreate(bitmapData, size.width, size.height,8,bitmapBytesPerRow,
CGColorSpaceCreateDeviceRGB(),kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(bitmapContext, (CGRect){CGPointZero,size}, img.CGImage);
CGImageRef imgRef = CGBitmapContextCreateImage(bitmapContext);
CIImage *cii = [CIImage imageWithCGImage:imgRef];
UIImage *finalImage = [UIImage imageWithCIImage:cii];
UIImageView *uiiv = [[UIImageView alloc] initWithImage:finalImage];
[self.canvas addSubview:uiiv];
}
UIImage , , , , CIImage. CIImage UIImage ... , , , , CIImage ARGB, UIImage ... ?
?