device-pixel-exact bitmap rendering
device-pixel-exact bitmap rendering
- Subject: device-pixel-exact bitmap rendering
- From: Kurt Bigler <email@hidden>
- Date: Sun, 18 Dec 2016 00:15:49 -0800
I have an NSView whose entire contents consist of a single
programatically-generated CGImage. It is drawn by drawRect: using
CGContextDrawImage. I need the image to be rendered pixel-exact on retina
displays, meaning device-pixel-exact.
I know that I will be encouraged to do this in the ultimately perfect way, but
for now I will be happy to know that it can be done at all. At the moment I
don't need things to be perfect on windows that cross multiple displays, for
example. But I would like a demo app to be working, say, tomorrow, and I have
an app that works now but with problematic limitations.
The doc states that the backing store scale factor for an NSView is always
either 1.0 or 2.0 and if there were any doubt about what that meant also says
"The fact that the backing scale factor is always a whole number is another key
feature of high resolution". The doc page in question, "High Resolution
Explained: Features and Benefits" doesn't suggest that there could be any
exception to that restriction.
However when I see discussions of a lot of functionality that I so far know
nothing about, including CALayer, hints at the possibility that a view might
*not* have a backing store (or is it only not "layer backed"?), the existence of
the makeBackingLayer method, and the possibility of setting contentsScale
property of a CALayer, then it gives me hope there might be a solution.
I hope it's clear that the 1.0 or 2.0 restriction is a problem for the basic
requirement of device-pixel-exact bitmap rendering.
Although I know I need to embrace the abstractions fully, I'd appreciate
feedback with priority to nuts-and-bolts. The abstraction in which the doc is
buried has seemed a little unhelpful in trying to understand simple needs.
Since I want concrete feedback I will give a concrete example of the limitation
as it affect me. (It would be lovely if the doc even touched this level of
concreteness.)
If my retina MBP which has a device resolution of 2880x1800 is set in Displays
to 1440x900 "Default", then my app works fine: the CGImage can be rendered
pixel-exact at 2880x1800 resolution. (The controls are too big and I can't get
much on my screen, but my bitmap content is rendered perfectly.) The backing
store scale factor in this case is 2.0. This means the backing store matches
the 2880x1800 display resolution, so my high-detail bitmap is rendered without
destruction.
But if in Displays I set the resolution to 1920x1200 "More Space", then I can't
get the backing store to match the 2880x1800 physical display resolution. I
need my NSView's backing store scale factor to be 1.5, but the doc says this is
impossible. As things are currently coded, my image gets smaller, and I get
weird artifacts in high-contrast high-resolution information. Presumably the
backing store resolution is 3840x2400.
Note I am using kCGInterpolationNone as would be required for pixel-exact
bitmaps. If I use anti-aliasing the problem of course gets less obviously
objectionable, but lacks the crispness which is required for this content.
Thanks for any help.
-Kurt Bigler
_______________________________________________
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