On Mar 14, 2016, at 12:55 , Steve Mills <sjmi...@mac.com> wrote:
> 
> The cropped NSImage is created at the scaled-up size, drawn into, and finally 
> the cropped NSImage's first NSImageRep is set to draw at the perceived, 
> high-res size via [cropped.representations.firstObject 
> setSize:perceivedSize]. This all works when the MathML string is long enough, 
> but when it is short, it doesn't. The setSize ends up reducing the pixels, 
> even though the image rep's pixelWidth and pixelHeight still report the 
> correct high-res size.

It’s not clear what your intention is, in trying to set the size of the image 
rep. It’s a NSBitmageImageRep, right? The pixels are the pixels are the pixels, 
so I don’t think you should be doing anything to the image *rep* size.

> An example of one that does NOT work is 88px high and 107px wide at the 
> scaled-up size (13px high x 16px wide at the perceived size).

Normally, if you have a bitmap image (i.e. NSBitmageImageRep) that’s actually 
88px x 107px, but you want to appear as 13pt x 16pt — note points not pixels — 
you would set the NSImage size to CGSize (13, 16)** and let the drawing system 
determine how to scale the pixel data to the perceived image size.

The other problem here is that you’re drawing the “hi-res” data at about 7x, 
which means that you’re guaranteeing some loss of detail when the image is 
scaled down to its final physical size (2x or 3x, or even 1x on a very old 
Mac). Why not draw it at the correct pixel resolution for the current display, 
so that there’s no actual pixel scaling (interpolation) needed when drawing? 
That should produce better quality than what you’re doing. (Unless you’re 
drawing something to be cached for multiple pixel resolutions, but even then 
there’s no hardware resolution higher than 3x).

Note that things are a bit complicated these days, because they pixel 
resolution of a display may be different from the rendering/backing store 
resolution and both may be different from the nominal resolution.


** Except that you’d probably want to preserve the aspect ratio, but 88.0/13 != 
107.0/16.
_______________________________________________

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