Re: Drawing to NSImage to create image data at different resolutions
Re: Drawing to NSImage to create image data at different resolutions
- Subject: Re: Drawing to NSImage to create image data at different resolutions
- From: Antonio Nunes <email@hidden>
- Date: Thu, 12 Apr 2007 17:03:55 +0100
On Apr 12, 2007, at 12:05 PM, Antonio Nunes wrote:
I want to capture some drawing that is normally performed to draw
to the screen or to print or to produce PDF output (the differences
are minimal), and produce a graphic from that drawing at n-dpi,
then save that graphic to disk. How can I control the resolution at
which the drawing is captured/the resolution at which the graphic
is created? Maybe using NSImage is not the best way to go?
Well, this is turning into a monologue it seems :-) Anyway:
I'm getting the results I want by calculating the factor required
to scale to the desired dpi (dpi/72.0), creating an NSImage of the
size of (drawingSize * factor) and applying a scaled transform
after locking focus on the new image but before drawing. When done
drawing I get the requested representation (e.g. TIFF, JPEG, PNG)
into an NSData object and write it to disk.
It still feels like this is not the jazzy way to do it though.
-António
----------------------------------------------------
There is a world of difference between
searching for happiness and choosing
to be happy.
----------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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