• 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: Sun, 18 Aug 2013 22:16:47 +0700

On 18 Aug 2013, at 21:03, Tom Davie <email@hidden> wrote:

>
> On 18 Aug 2013, at 15:56, Gerriet M. Denkmann <email@hidden> wrote:
>
>>
>> On 18 Aug 2013, at 20:09, Tom Davie <email@hidden> wrote:
>>
>>>
>>> On 18 Aug 2013, at 15:03, Gerriet M. Denkmann <email@hidden> wrote:
>>>
>>>> I just noticed that the program I use to create Png files creates files with twice the number of pixels in each dimension.
>>>> Obviously because since I last used it, I have switched to a Retina Mac Book.
>>>>
>>>> Ok, so I have to fix this program.
>>>
>>> The correct way to fix this problem is to create an image via CGContextCreate and CGContextCreateImage.  When doing this you specify pixel rather than point dimensions, and do not have the issue you’re experiencing.  You detect a retina device by testing scaleFactor as you suggested, it’s just unnecessary here.
>>
>> I just asked Xcode about CGContextCreate and it told me that there is absolutely no information available.
>> Could anybody help me with some link to some documentation?
>
> Uhh sorry, my bad, I meant CG*Bitmap*ContextCreate…
>
> http://developer.apple.com/library/ios/documentation/graphicsimaging/Reference/CGBitmapContext/Reference/reference.html

Ah, now I found lots of info!

But I do not understand it. CIImage, CGImage, NSImage, UIImage... This is just too much for my small brain.

I removed:
 		finalWidth /= 2;	//	Retina Fix 18.Aug. 2013
and replaced:
 		NSImage *image = [[NSImage alloc] initWithSize: sizE];
by:
size_t pixelsWide = (size_t)sizE.width;
size_t pixelsHigh = (size_t)sizE.height;
size_t bitmapBytesPerRow = pixelsWide * 4;
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);

CGContextRef c = CGBitmapContextCreate ( NULL, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, (CGBitmapInfo)kCGImageAlphaPremultipliedLast);
CGImageRef cgImage = CGBitmapContextCreateImage ( c );
NSImage *image = [[NSImage alloc] initWithCGImage: cgImage size: NSZeroSize ];
(ignoring leaks for the time being)
... and then continued with my old code.

The png is still 100 pixels wide.

You see, I am rather clueless.

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: Alex Zavatone <email@hidden>
    • Re: How to detect a Retina Mac
      • From: Marcel Weiher <email@hidden>
    • Re: How to detect a Retina Mac
      • From: Lee Ann Rucker <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>)

  • Prev by Date: Re: How to detect a Retina Mac
  • 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