discuss-gnustep
[Top][All Lists]
Advanced

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

Re: TIFFRpresentation problem


From: Renaud Molla
Subject: Re: TIFFRpresentation problem
Date: Thu, 8 Mar 2007 10:17:32 +0100

You're right. It's got to be synchronized each time one tries to grab the tiffrepresentation...
how to detect if an image has been altered?

Regards.

On Mar 8, 2007, at 10:09 AM, Fred Kiefer wrote:

Renaud Molla wrote:
I experimented a few ways to make the same work with Cocoa and GNUstep.
So here is the result.

At the beginning I was doing this:

[ anImage lockFocus ];
// Draw...
[ anImage unlockFocus ];

data = [ anImage TIFFRepresentation ];

-> Works with Cocoa, should be working with GNUstep but current
implementation doesn't support it.

Then tried:

NSBitmapImageRep ir = [ [ NSBitmapImageRep alloc ]
initWithBitmapDataPlanes: ..... ];
[ anImage addRepresentation: ir ];
[ anImage lockFocusOnRepresentation: ir ];

// Draw

[ anImage unlockFocus ];
data = [ ir TIFFRepresentation ];

--> yields an empty/transparent image (i think because my bitmap was
supporting transparency)

WORKING CODE FOLLOWS:

[ anImage lockFocus ];
// Draw...
[ anImage unlockFocus ];

//...some code... but i think could be collapsed if needed within the
previous lockFocus/unlockFocus pair

[ anImage lockFocus ];
ir = [ [ NSBitmapImageRep alloc ] initWithFocusedViewRect: NSMakeRect(
0.0, 0.0, imageWidth, imageHeight ) ];
[ anImage unlockFocus ];
data = [ ir TIFFRepresentation ];

So, I think, the most simple thing to do in order to get a working
NSImage -(NSData *)TIFFRepresentation is:

If there is already a bitmap rep available, then return its
TIFFRepresentation data.
If not, create one with the code above and add the representation in the
rep set for the image, then return the TIFFRepresentation.

What do you thing about this?
I don't think this is the best way to go, but this should work.


I like this idea. It is straight forward and simple to implement. There
are still a few drawbacks. When would we create this new bitmap
representation and when output an existing one? The existing one will
always miss out on the newly drawn bits. Should we add this bitmap
representation to the image?
Anyway, even with this limitations it is better then what is currently
there. I will add it to gui.

Cheers,
Fred


---------------------------------------------------------------------- ----------------- Orange vous informe que cet e-mail a ete controle par l'anti-virus mail.
Aucun virus connu a ce jour par nos services n'a ete detecte.









reply via email to

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