[CIImageAccumulator image]: getting the BMP representation destroys the image contents
[CIImageAccumulator image]: getting the BMP representation destroys the image contents
- Subject: [CIImageAccumulator image]: getting the BMP representation destroys the image contents
- From: Nick <email@hidden>
- Date: Sat, 07 Feb 2015 01:23:38 +0200
Hello,
I am playing with the CIMicroPaint sample code (
https://developer.apple.com/library/mac/samplecode/CIMicroPaint). This is
basically a simple paint editor (you can draw on a view with a mouse using
CoreImage).
I would like to save whatever is drawn into a file. So what I do is call
this, when the save button is pressed:
-(IBAction)saveButton:(id)sender {
NSBitmapImageRep *bir = [[NSBitmapImageRep alloc] initWithCIImage:self.
imageAccumulator.image];
NSData *bmpData = [bir representationUsingType:NSBMPFileType properties:
nil]; //THIS LINE CORRUPTS THE CIImageAccumulator.image. WHY?
[bmpData writeToFile:[@"~/test.bmp" stringByExpandingTildeInPath]
atomically:YES];
//NSImage *img = [[NSImage alloc] initWithData:bmpData];
//imageView.image = img;
}
This is the only code i added to the original Apple sample code.
The problem i have is that i can call representationUsingType only once to
get the bmpData that i can save to disk as an image.
If i draw something, and call it again later, i will get the old image,
not the updated one. Also the commented imageView code shows the same
problem - the NSImageView gets updated only the first time, not the
subsequent times.
What can be the cause of this?
It really looks like a bug in Apple framework code. Or is it me doing
something wrong?
I have found similar problem/questions, but they hasn't been answered:
http://stackoverflow.com/questions/23009472/ciimage-converted-to-nsdata-or-nsimage-seems-to-lose-changes-made-to-the-ciimage
http://stackoverflow.com/questions/26075375/ciimage-obtained-from-ciimageaccumulator-after-converting-to-nsdata-is-corrupted
Thank you!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden