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 08:36:42 +0100

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.

Regards.
PS: I started this thread, but accidentally posted from a different address.

On Mar 8, 2007, at 12:07 AM, Fred Kiefer wrote:

Vaisburd, Haim wrote:
Fred Kiefer wrote:

Half Activist wrote:

    i wrote a little application, that locks focus on an NSImage,
draws to it, then unlock the focus.
    I then try to get the TIFFRepresentation data, but it always
returns nil.

This currently is a limitation of GNUstep.

I'm among the ones who would be very pleased to get this working.


Should we create bitmap representations for images as well and draw
into them
or allow to grap the content of a cached image representation and
return it as tiff?
The later may not be to hard to implement.

What would be the difference for the user? I do not know internals well
enough
to make an opinion, my own attitude is to strive for clarity and use the
most
straigtforward approach.

It would be really great to have
[NSBitmapImageRep -representationUsingType:properties:] also working,
at least for JPEG.


Sorry, I don't want to sound negative, but there are a lot of bits
missing in GNUstep that would be great to have. Contributions are more
than welcome.

Fred


_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep
---------------------------------------------------------------------- ----------------- 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]