Chapter 9. Importing and Exporting Images


Computers are riddled with image files in popular formats such as JPEG, PNG, GIF, TIFF, and many others. In addition there are a number of powerful tools available on Mac OS X that graphic artists can use to create image resources for an application. Fortunately, Mac OS X makes it remarkably easy to import many kinds of image files into CGImages that you can draw in your application.

In a similar fashion, it is nice to be able to take the graphics you have created in your application and export them to image files for use by others. The operating system also includes technologies that let you take the images your application creates and export them into graphics files on disk.

This chapter looks at two of the technologies, QuickTime and Image I/O, that Mac OS X offers for importing and exporting images and discusses some of the features that these libraries offer. Some basic code samples are offered that demonstrate the fundamentals of using these technologies to read and write image files.

QuickTime is well known as a technology for recording and presenting multiple media types including video and sound. QuickTime also includes components for reading and writing still image files in a number of formats. Using a few lines of QuickTime code in your application will make it able to read and write image files in several different formats.

Image I/O is a technology Apple introduced in Mac OS X 10.4 Tiger. The Image I/O API provides a mechanism for importing and exporting images from a broad variety of image file types. The library supports many formats including open-source-based floating point image file formats (a.k.a. High Dynamic Range images) like OpenEXR and LogLUV TIFF images. Image I/O includes the ability to import individual images from files in formats that support storing more than one picture per file. The native compressors and decompressors in Image I/O are highly optimized and allow for the progressive loading of image data should the application desire that. The library also includes routines for working with and creating image thumbnails and can help your application read and write image meta data.

Image I/O understands how to make use of the QuickTime importers and exporters as a fallback mechanism. This means that if Image I/O is asked to read or write a file it does not understand natively, it can make use of any QuickTime components that can work with that format. In this way, applications that use the Image I/O API capitalize on the benefits of both libraries.

Image I/O is the preferred mechanism for importing and exporting images on versions of the operating system starting with Mac OS X 10.4 Tiger. This technology is used by all the system services on that operating system that work with images. If your application needs to support older versions of the operating system, you can fall back to using QuickTime, but the additional functionality found in Image I/O will add value when the library is available.




Quartz 2D Graphics for Mac OS X Developers
Quartz 2D Graphics for Mac OS X Developers
ISBN: 0321336631
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net