discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessing bitmap representation, NSImage


From: Riccardo Mottola
Subject: Re: accessing bitmap representation, NSImage
Date: Sun, 30 Nov 2014 00:00:08 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:33.0) Gecko/20100101 Firefox/33.0 SeaMonkey/2.30

Hi,

Dr. H. Nikolaus Schaller wrote:
Finally, you can alloc+init an NSImage and use addRepresentation to add exactly 
this rep. And then you can draw. Even if it then magically converts it into a 
NSCachedImageRep, you still have access to the original.

Maybe this caching is triggered by the first draw operation, so if you get the 
representations before doing any draw operation on the NSImage, you could also 
get the uncached version first and retain it…
I came to similar conclusions and initially I had the same ideas, thus they look god and you confirmed the path to follow. I implemented it in a NSImage subclass.

In initWithData I set a pointer to the representation (only on at this point) and also retain it. This way if later the drawin code replaces it I can still access it. I thought that in the representations array I would have several device-dependent versions, but that the first rep would be my original. Since it is not the case, this way I can always access it. Of course, I added an accessor to this representation which just returns the pointer.

At release, I send an additional release to it.

I had to modify PRICE to use my accessor instead of the representation array when I need direct access to the data Furthermore, when doing a copy of the image, instead of instantiating every time a new image and copying the representation, I implemented the copyWithZone method, so that my original representation can be copied.

It works uite fine on the Mac, on GNUstep however I get horrible crashes, I'll clean up the code first then try to be more precise about the conditions that trigger it on GNUstep. But I fear it is GS problem now.

Riccardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]