An NSValueTransformer that enables bindings to use Jpeg2000 compression rather than just the raw TIFF data.
I’ve hand tuned the compression parameter to show no compression artifacts for my test images. You may wish to increase it. � BryanWoods
// Jpeg2kValueTransformer @interface Jpeg2kValueTransformer : NSValueTransformer
@end
// Jpeg2kValueTransformer.m #import “Jpeg2kValueTransformer.h”
@implementation Jpeg2kValueTransformer
(Class) transformedValueClass; { return [NSData class]; }
(BOOL) allowsReverseTransformation; { return YES; }
(id) transformedValue:(id)value; { return [[NSBitmapImageRep imageRepWithData:value] TIFFRepresentation]; }
(id) reverseTransformedValue:(id)value; { return [[NSBitmapImageRep imageRepWithData:value] representationUsingType:NSJPEG2000FileType properties:[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.4f] forKey:@”NSImageCompressionFactor”]]; }
@end
Note that NSJPEG2000FileType is only available in Mac OS X v10.4 and later.
Some notes