Dan Wood: The Eponymous Weblog

Dan Wood is co-owner of Karelia Software, creating programs for the Macintosh computer. He is the father of two kids, lives in the Bay Area of California USA, and prefers bicycles to cars. This site is his weblog, which mostly covers geeky topics like Macs and Mac Programming.

Useful Tidbits and Egotistical Musings from Dan Wood

Categories: Mac OS X · Cocoa Programming · General · All Categories

Mon, 09 May 2005

As I mentioned in my previous post, scaling with CIImage can be a bit tricky, if you want to do it just right.

First off, the main CIFilter you should use is CILanczosScaleTransform. Originally I started using an affine transformation, which was in some Apple sample code, but that didn't produce as good of a result. You pass in the scale (along the Y dimension) that you want the image resized to, and an aspect ratio, usually of 1.0 unless you want something anamorphic going on. Here's a fragment:

See more ...

By now, developers have probably seen some of the demos of Core Image, or played with it using programs like Apple's Core Image Fun House (in /Developer/Applications/) or Stone's similar iMaginator. The list of image processing features that are built-in are pretty amazing, and you can make some wild effects.

But Core Image is about more than just cool effects; it's also a great workhorse. When we decided that our forthcoming application would be Tiger-only, I started experimenting with Core Image to try and speed up some of our basic image processing needs, such as simple scaling of images. I don't have any benchmarks comparing image-scaling between NSImage and Core Image, but it's noticeably faster. Plus, you can take advantage of some subtle techniques to make your processed images look great.

See more ...