rmvz3
rmvz3

Reputation: 1173

NSImage from two NSImages

I have a rectangular NSImage A and I want to scale to embed into a squared transparent image B keeping A's ratio. So, in the end I'll get a squared image with the rectangle in it.

How can I compose that image?. I mean, how can I draw an NSImage over another NSImage and save the resulting image?.

I've been reading about clipping an NSImage inside a beizer but I need to keep ratio instead of filling the beizer square.

I hope you understand what I want.

Thanks.

Upvotes: 1

Views: 523

Answers (1)

GoZoner
GoZoner

Reputation: 70135

The 'Cocoa Drawing Guide' has a section called 'Drawing to an Image'. From that documentation:

It is possible to create images programmatically by locking focus on an NSImage object and drawing other images or paths into the image context. This technique is most useful for creating images that you intend to render to the screen, although you can also save the resulting image data to a file.

There is example code there.

Upvotes: 3

Related Questions