On Oct 10, 2014, at 1:02 AM, Graham Cox <graham....@bigpond.com> wrote:
> 
> // ... set up destination context ...
> 
> [[NSGraphicsContext currentContext] setImageInterpolation: 
> NSImageInterpolationHigh];
> [sourceImage drawInRect:dest fromRect:NSZeroRect operation:NSCompositeCopy 
> fraction:1.0 respectFlipped:YES hints:nil];
> 
> // ... clean up leaving NSBitMapImageRep alone...
> 
> NSData* imageData = [destBitMapRep representationUsingType:... properties:…];

Thanks Graham and Ken! You’re right, no need at all for the CIImage (flail) 
step. Here’s my cleaned-up code, combining both your inputs, works perfectly. 
Anything still superfluous here? 
-Carl

    . . .
    NSRect imgRect = NSMakeRect(0.0, 0.0, 640.0, 480.0);
    NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc]
                                       initWithBitmapDataPlanes:NULL
                                                     
pixelsWide:imgRect.size.width
                                                     
pixelsHigh:imgRect.size.height
                                                  bitsPerSample:8
                                                samplesPerPixel:4
                                                       hasAlpha:YES
                                                       isPlanar:NO
                                                 
colorSpaceName:NSDeviceRGBColorSpace
                                                   
bitmapFormat:NSAlphaFirstBitmapFormat
                                                    bytesPerRow:0
                                                   bitsPerPixel:32];
    NSGraphicsContext *gc = [NSGraphicsContext 
graphicsContextWithBitmapImageRep:offscreenRep];
    [NSGraphicsContext saveGraphicsState];
    [NSGraphicsContext setCurrentContext:gc];
    [[NSGraphicsContext currentContext] setImageInterpolation: 
NSImageInterpolationHigh];
    [srcImage drawInRect:imgRect fromRect:NSZeroRect operation:NSCompositeCopy 
fraction:1.0 respectFlipped:YES hints:nil];
    [NSGraphicsContext restoreGraphicsState];
    NSData *dataObj = [offscreenRep representationUsingType:NSJPEGFileType 
properties:nil];
    . . .

* Final NSImage: <NSImage 0x608000073f80 Size={640, 480} Reps=(
    "NSBitmapImageRep 0x6080000a9d20 Size={640, 480} ColorSpace=(not yet 
loaded) BPS=8 BPP=(not yet loaded) Pixels=640x480 Alpha=NO Planar=NO 
Format=(not yet loaded) CurrentBacking=nil (faulting) 
CGImageSource=0x60800016e700"
)>


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to