On 19 Aug 2013, at 06:41, Marcel Weiher <[email protected]> wrote:

My problem is: "... some drawing here ..." seems to assume a locked NSImage in 
place.
It looks like:
                NSUInteger graphicIndex = [graphics count];
                while (graphicIndex-- > 0) 
                {
                    SKTGraphic *graphic = graphics[graphicIndex];
                    [currentContext saveGraphicsState];
                        
                        // next line uses "current graphics context"
                    [NSBezierPath clipRect:[graphic drawingBounds]];
                        
                        //      next line will do e.g. NSBezierPath stroke and 
drawGlyphsForGlyphRange:atPoint:
                        //      for the latter: "focus must already be locked 
on the destination view or image"
                    [graphic drawContentsInView:nil isBeingCreateOrEdited:NO];
                        
                    [currentContext restoreGraphicsState];
                };

so drawing directly via CGContext... stuff is not really an option. 

I tried:
                NSImage *image = [[NSImage alloc] initWithSize: sizE];
                NSBitmapImageRep *imageRep =    [ [ NSBitmapImageRep alloc ]    
initWithBitmapDataPlanes:...
                [ image addRepresentation: imageRep ];
                [image lockFocus];
                "... some drawing here ..." (see above)
                [image unlockFocus];
At this point my image has a representation: <NSCGImageSnapshotRep:0x100675b60 
cgImage=<CGImage 0x100675a80>>
but my carefully crafted NSBitmapImageRep has been ignored and removed.


I also tried (before [image lockFocus]:
                NSGraphicsContext *bitmapContext = [ NSGraphicsContext 
graphicsContextWithBitmapImageRep: imageRep ];
                [NSGraphicsContext setCurrentContext: bitmapContext ];
But after  [image lockFocus] the currentContext changes to: 
NSSnapshotBitmapGraphicsContext.


I seem to need a way to tell NSImage NOT to double the pixels for me, but I 
don't see any way to do this.
Like: [ image setBackingScaleFactor: 1 ] but no such method seems to exist.


So hardcoding the retina-ness of my current computer seems to be the only 
solution.

Kind regards,

Gerriet.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to