Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Start Code/DrawImage.c
// Graphics Importer and Exporter Samples |
// This sample simply draws an image from a file using Graphics Importers |
// Originally written by Sam Bushell for QuickTime "Live" '99 |
// WWDC 2000 Introduction to QuickTime |
#include "MacShell.h" |
void DrawImage( void ) |
{ |
OSErr err = noErr; |
Handle hOpenTypeList = NewHandle(0); |
long numTypes = 0; |
FSSpec theFSSpec; |
Rect bounds; |
GraphicsImportComponent importer = 0; |
WindowPtr window = NULL; |
BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); |
HLock( hOpenTypeList ); |
err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); |
DisposeHandle( hOpenTypeList ); |
if ( err ) return; |
// locate and open a graphics importer component which can be used to draw the |
// selected file. If a suitable importer is not found the ComponentInstance |
// is set to NULL. |
// Step 1. Insert GetGraphicsImporterForFile.clp here... |
// get the native size of the image associated with the importer |
// Step 2. Insert GetNaturalBounds.clp here... |
OffsetRect( &bounds, 10, 45 ); |
window = NewCWindow( NULL, &bounds, "\pDraw Image", true, documentProc, (WindowPtr)-1, true, 0); |
// set the graphics port for drawing |
// Step 3. Insert GraphicsImportSetGWorld.clp here... |
// draw the image |
// Step 4. Insert GraphicsImportDraw.clp here... |
// close the importer instance |
// Step 5. Insert CloseComponent.clp here... |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14