0

I am trying to render a few images in NSImageView's. These images are much larger than the size of the NSImageView (which I have set to scale proportionally up or down). But, the rendered image don't look very good. For example, in this sample image, the white border seems to have jagged edges at the 12,3,6 and 9 o'clock positions. The source image seems to be fine, even when I zoom out all the way in Preview.app.

I have tried scaling the image myself (using MGCropExtensions - which sets the interpolation quality to High), but, it doesn't seem to help. I would imagine NSImageView would internally draw on device boundary automatically, so that shouldn't be an issue?

Any ideas on how to get the image rendered crisply in the NSImageView? Thanks

Source Image - It has a white border which doesn't show here (against the white background)

Source Image

Rendered NSImageView screenshot

enter image description here

georgemp
  • 716
  • 10
  • 21
  • Interesting suggestion here: http://stackoverflow.com/a/14878177/341994 – matt Sep 26 '16 at 18:31
  • @matt - Thanks. The extension I am using does pretty much what that link suggests, except, that it also takes care of maintaining the aspect ratio. Nevertheless, I tried out the code from that link, and I still see the same image output - with the jagged edges :( – georgemp Sep 26 '16 at 18:51
  • Thanks for reporting back. I guess I don't think there's much more you can do. Such a big size reduction is inherently lossy: pixels must be ejected like mad, and compromises must be made. If the only issue is the white border, I'd suggest drawing that yourself _at the smaller size_ (you can do that in code, you understand); a drawn circle of a given size is always going to look better than a great big circle reduced in size. – matt Sep 26 '16 at 19:16
  • @matt - Unfortunately, the images are from a rest api feed, and, I have no way of knowing which ones will have the circular border (or colour of border etc). I was hoping to be able to scale this better, as if I open the original image in preview.app and zoom out (to even minimum zoom - which on screen is smaller than my NSImageView size), it renders it without any jagged edges on the border – georgemp Sep 26 '16 at 19:22
  • This isn't perfect - but, it's visually more pleasing than earlier. I scale the image to a size which is a few pixels greater than my NSImageView frame size (by about 3-5 pixels). Then, I set the NSImageView scaling to none and layer corner radius to be half it's width. This forces a circular avatar like image rendition, without the jagged edges (which are essentially cropped out) – georgemp Sep 26 '16 at 21:14

0 Answers0