> On Feb 6, 2015, at 18:23, Nick <eveningn...@gmail.com> wrote:
> 
> 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?

This is a guess because I have never used this class, but it sounds like a 
caching problem.  I don't know if CIImage and the accumulator are prone to 
similar caching problems like NSImage had (regarding -cacheMode and 
NSImageCacheNever and -setDataRetained:YES).  If you copy the CIImage data from 
the accumulator and initialize your image rep with the copy, does the problem 
go away?

> 
>     [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?

Sandor
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to