Re: Obtaining unpremultiplied bitmap from PNG file
Re: Obtaining unpremultiplied bitmap from PNG file
- Subject: Re: Obtaining unpremultiplied bitmap from PNG file
- From: David Duncan <email@hidden>
- Date: Mon, 18 Jun 2007 12:58:08 -0700
On Jun 18, 2007, at 10:11 AM, Chiharu Hirono wrote:
The final goal of may app is to make smaller picture from original
picture without modifying RGBA or gamma or resizing.
I'm not certain I understand your goal. You want to create a smaller
image without modifying the pixels or resizing the image? Creating a
smaller image typically involves at the least changing the pixels
that comprise that image.
Or do you mean changing the DPI of the image to save back to disk? If
that is the case, then that is fairly simple to do.
1) Open the image via Image I/O (CGImageSourceCreateWithURL)
2) Obtain the image properties from the source image
(CGImageSourceCopyPropertiesAtIndex)
3) Modify the kCGImagePropertyDPIHeight & kCGImagePropertyDPIWidth
properties in that dictionary (you will need to make a copy of it) to
state the new vertical & horizontal DPI.
4) Create a destination for the new image
(CGImageDestinationCreateWithURL) in your desired format
5) Add the image from the source to the destination
(CGImageDestinationAddImageFromSource)
6) Finalize the destination image and clean up.
This should create a new image without touching the pixel data while
updating the DPI of the image, which will modify the display size.
This is NOT how you should create a smaller image for display on the
monitor however, for that you should just let the OS resize the image
(it won't alter the original image, just the pixels on the screen).
--
David Duncan
Apple DTS Quartz and Printing
email@hidden
_______________________________________________
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