• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to detect a Retina Mac
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect a Retina Mac


  • Subject: Re: How to detect a Retina Mac
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Mon, 19 Aug 2013 14:01:40 +0700

On 19 Aug 2013, at 06:41, Marcel Weiher <email@hidden> 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@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: How to detect a Retina Mac
      • From: Lee Ann Rucker <email@hidden>
    • Re: How to detect a Retina Mac
      • From: Simone Tellini <email@hidden>
References: 
 >How to detect a Retina Mac (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to detect a Retina Mac (From: Tom Davie <email@hidden>)
 >Re: How to detect a Retina Mac (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to detect a Retina Mac (From: Tom Davie <email@hidden>)
 >Re: How to detect a Retina Mac (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to detect a Retina Mac (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Why is translatesAutoresizingMaskIntoConstraints on in my storyboard?
  • Next by Date: Re: How to detect a Retina Mac
  • Previous by thread: Re: How to detect a Retina Mac
  • Next by thread: Re: How to detect a Retina Mac
  • Index(es):
    • Date
    • Thread