Le 21 mars 06 à 18:07, Yen-Ju Chen a écrit :
On 3/21/06, Banlu Kemiyatorn <[EMAIL PROTECTED]> wrote:
On 3/20/06, Yen-Ju Chen <[EMAIL PROTECTED]> wrote:
An easy way is by returning bitmap representation
for any unknown type and use image magic to
generate tiff stream.
But it adds a dependency on image magic.
Since several people are writting a WM,
it may be worth to have XPM support in NSImage. :D
Yes :-)
The file format of XPM is relatively simple in my opinion.
I just cannot figure how to put stuff into NSImage.
You shouln't put the code in NSImage but in NSBitmapImageRep or
precisely in an NSBitmapImageRep category.
Here is NSBitmapImageRep header : <http://svn.gna.org/viewcvs/gnustep/
libs/gui/trunk/Headers/AppKit/NSBitmapImageRep.h>
The method to create an image rep with an image in a particular
format is
- (id) initWithData: (NSData *)imageData
Within this method we have the following code which calls concrete
category implementation for each image format :
if ([isa _bitmapIsPNG: imageData])
return [self _initBitmapFromPNG: imageData];
if ([isa _bitmapIsPNM: imageData])
return [self _initBitmapFromPNM: imageData
errorMessage: NULL];
if ([isa _bitmapIsJPEG: imageData])
return [self _initBitmapFromJPEG: imageData
errorMessage: NULL];
if ([isa _bitmapIsGIF: imageData])
return [self _initBitmapFromGIF: imageData
errorMessage: NULL];
_initBitmapFromXXX methods are in fact calling on their side the
method 'initWithBitmapDataPlanes:blabla' to set up correctly the new
NSBitmapImageRep; here is the complete method signature related to
'initWithBitmapDataPlanes:blabla' :
- (id) initWithBitmapDataPlanes: (unsigned char**)planes
pixelsWide: (int)width
pixelsHigh: (int)height
bitsPerSample: (int)bps
samplesPerPixel: (int)spp
hasAlpha: (BOOL)alpha
isPlanar: (BOOL)isPlanar
colorSpaceName: (NSString*)colorSpaceName
bytesPerRow: (int)rowBytes
bitsPerPixel: (int)pixelBits;
Here is a concrete category example for PNG :
<http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/
NSBitmapImageRep%2BPNG.h>
<http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/
NSBitmapImageRep%2BPNG.m>
The method to ouput an image rep in a particular image format is
- (NSData *)representationUsingType:(NSBitmapImageFileType)storageType
properties:(NSDictionary *)properties;
Then you can write the returned data to a file, but for now this
method isn't implemented at all in GNUstep :-/
That means at this time it isn't possible to write image files in any
formats except TIFF.
Supporting writing would mean implement this previous method and add
a concrete private method for each image format categories. The
method name would be something like :
- (NSData *) _representationUsingPNGWithProperties:(NSDictionary *)
properties;
Hope it helps,
Quentin.
--
Quentin Mathé
[EMAIL PROTECTED]
_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss