Re: Obtaining unpremultiplied bitmap from PNG file
Re: Obtaining unpremultiplied bitmap from PNG file
- Subject: Re: Obtaining unpremultiplied bitmap from PNG file
- From: Chiharu Hirono <email@hidden>
- Date: Wed, 20 Jun 2007 02:27:36 +0900
Hi David,
Thank you for quick response.
On 2007/06/19, at 4:58, David Duncan wrote:
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.
My goal is like getting star and blue background area from flag of
the United states,
deleting red and white stripe area.
The size of star and blue background area, RGBA of this area and
gamma should not
changed.
In this example, alpha is not needed because whole area is opaque,
but my app
pick up area with alpha (0 < alpha <= 1).
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