user1548418
user1548418

Reputation: 497

How to create multi-resolution (Retina-ready) NSImage programmatically at runtime?

I have two button images, say "myButton.png" and "[email protected]" in my app's bundle resources. At run time, I load the image using [NSImage imageNamed:@"myButton"] and need to split it into three slices and create three NSImages to use in NSDrawThreePartImage() function.

The problem is that each slice NSImage needs to be multi-resolution, so that the system could pick the right resolution dynamically, as it would automatically do with the original whole image.

How do you create the automatic multi-resolution NSImage programmatically? Thanks!

Upvotes: 1

Views: 627

Answers (1)

Rafael Bugajewski
Rafael Bugajewski

Reputation: 1712

I think the appropriate solution is to store the image parts in different images and don’t try to code a workaround that splits one image into three parts. This way you can use NSDrawThreePartImage() directly and in the most efficient manner.

Upvotes: 1

Related Questions