forked from cellularmitosis/ADC-reference-library-2009-july
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisting75.html
executable file
·392 lines (347 loc) · 17.3 KB
/
listing75.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<!-- BEGIN META TAG INFO -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="home" href="http://developer.apple.com/">
<link rel="find" href="http://developer.apple.com/search/">
<link rel="stylesheet" type="text/css" href="../../documentation/css/adcstyle.css" title="fonts">
<script language="JavaScript" src="../../documentation/js/adc.js" type="text/javascript"></script>
<!-- END META TAG INFO -->
<!-- BEGIN TITLE -->
<title>Graphic Import-Export - /Start Code/GettingMoreInfo.c</title>
<!-- END TITLE -->
<script language="JavaScript">
function JumpToNewPage() {
window.location=document.scpopupmenu.gotop.value;
return true;
}
</script>
</head>
<!-- BEGIN BODY OPEN -->
<body>
<!--END BODY OPEN -->
<!-- START CENTER OPEN -->
<center>
<!-- END CENTER OPEN -->
<!-- BEGIN LOGO AND SEARCH -->
<!--#include virtual="/includes/adcnavbar"-->
<!-- END LOGO AND SEARCH -->
<!-- START BREADCRUMB -->
<div id="breadcrumb">
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr>
<td scope="row"><img width="340" height="10" src="images/1dot.gif" alt=""></td>
<td><img width="340" height="10" src="images/1dot.gif" alt=""></td>
</tr>
<tr valign="middle">
<td align="left" colspan="2">
<a href="http://developer.apple.com/">ADC Home</a> > <a href="../../referencelibrary/index.html">Reference Library</a> > <a href="../../samplecode/index.html">Sample Code</a> > <a href="../../samplecode/QuickTime/index.html">QuickTime</a> > <a href="../../samplecode/QuickTime/idxImportExport-date.html">Import & Export</a> > <A HREF="javascript:location.replace('index.html');">Graphic Import-Export</A> >
</td>
</tr>
<tr>
<td colspan="2" scope="row"><img width="680" height="35" src="images/1dot.gif" alt=""></td>
</tr>
</table>
</div>
<!-- END BREADCRUMB -->
<!-- START MAIN CONTENT -->
<!-- START TITLE GRAPHIC AND INTRO-->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td><h1><div id="pagehead">Graphic Import-Export</div></h1></td>
</tr>
</table>
<!-- END TITLE GRAPHIC AND INTRO -->
<!-- START WIDE COLUMN -->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td id="scdetails">
<h2>/Start Code/GettingMoreInfo.c</h2>
<form name="scpopupmenu" onSubmit="return false;" method=post>
<p><strong>View Source Code:</strong>
<select name="gotop" onChange="JumpToNewPage();" style="width:340px"><option selected value="ingnore">Select File</option>
<option value="listing1.html">/Clippings/AlphaComposite.c/CenterForground.txt</option>
<option value="listing2.html">/Clippings/AlphaComposite.c/DrawBackground.txt</option>
<option value="listing3.html">/Clippings/AlphaComposite.c/Rotate.txt</option>
<option value="listing4.html">/Clippings/AlphaComposite.c/SetGraphicsMode.txt</option>
<option value="listing5.html">/Clippings/AlphaComposite.c/SetGraphicsModeAlpha.txt</option>
<option value="listing6.html">/Clippings/DrawImage.c/CloseComponent.txt</option>
<option value="listing7.html">/Clippings/DrawImage.c/GetGraphicsImporterForFile.txt</option>
<option value="listing8.html">/Clippings/DrawImage.c/GetNaturalBounds.txt</option>
<option value="listing9.html">/Clippings/DrawImage.c/GraphicsImportDraw.txt</option>
<option value="listing10.html">/Clippings/DrawImage.c/GraphicsImportSetGWorld.txt</option>
<option value="listing11.html">/Clippings/FilterExport.c/DoExport.txt</option>
<option value="listing12.html">/Clippings/FilterExport.c/OpenADefaultComponent.txt</option>
<option value="listing13.html">/Clippings/FilterExport.c/QTCopyAtomDataToPtr.txt</option>
<option value="listing14.html">/Clippings/FilterExport.c/QTFindChildByIndex.txt</option>
<option value="listing15.html">/Clippings/FilterExport.c/QTGetEffectsList.txt</option>
<option value="listing16.html">/Clippings/FilterExport.c/QTInsertChild.txt</option>
<option value="listing17.html">/Clippings/FilterExport.c/QTNewAtomContainer.txt</option>
<option value="listing18.html">/Clippings/FilterExport.c/SetDepth.txt</option>
<option value="listing19.html">/Clippings/FilterExport.c/SetOutputFile.txt</option>
<option value="listing20.html">/Clippings/FilterExport.c/StandardParameterDialog.txt</option>
<option value="listing21.html">/Clippings/FilterExport.c/Step1.txt</option>
<option value="listing22.html">/Clippings/FilterExport.c/Step8.txt</option>
<option value="listing23.html">/Clippings/GettingMoreInfo.c/DoesDrawAllPixels.txt</option>
<option value="listing24.html">/Clippings/GettingMoreInfo.c/GetCTable.txt</option>
<option value="listing25.html">/Clippings/GettingMoreInfo.c/GetImageDescription.txt</option>
<option value="listing26.html">/Clippings/GettingMoreInfo.c/GetMetaData.txt</option>
<option value="listing27.html">/Clippings/GettingMoreInfo.c/GetNextUserDataType.txt</option>
<option value="listing28.html">/Clippings/GettingMoreInfo.c/NewUserData.txt</option>
<option value="listing29.html">/Clippings/GettingMoreInfo.c/Step6.txt</option>
<option value="listing30.html">/Clippings/GettingMoreInfo.c/Variables.txt</option>
<option value="listing31.html">/Clippings/ImagesFromURL.c/ImporterForDataRef.txt</option>
<option value="listing32.html">/Clippings/MovieToImages.c/ConvertMovieToFile.txt</option>
<option value="listing33.html">/Clippings/MovieToImages.c/CreateMovieFile.txt</option>
<option value="listing34.html">/Clippings/MovieToImages.c/MovieExportDoUserDialog.txt</option>
<option value="listing35.html">/Clippings/MovieToImages.c/MovieImportDoUserDialog.txt</option>
<option value="listing36.html">/Clippings/MovieToImages.c/MovieImportFile.txt</option>
<option value="listing37.html">/Clippings/MovieToImages.c/OpenADefaultComponent1.txt</option>
<option value="listing38.html">/Clippings/MovieToImages.c/OpenADefaultComponent2.txt</option>
<option value="listing39.html">/Clippings/MovieToImages.c/Step8.txt</option>
<option value="listing40.html">/Clippings/MultipleImages.clp/GetImageCount.txt</option>
<option value="listing41.html">/Clippings/MultipleImages.clp/SetGraphicsMode.txt</option>
<option value="listing42.html">/Clippings/MultipleImages.clp/SetImageIndex.txt</option>
<option value="listing43.html">/Clippings/MultipleImages.clp/SetMatrix.txt</option>
<option value="listing44.html">/Clippings/ScaleAndRotate.c/Rotate.txt</option>
<option value="listing45.html">/Clippings/ScaleAndRotate.c/SetBoundsRect.txt</option>
<option value="listing46.html">/Clippings/ScaleAndRotate.c/Step1.txt</option>
<option value="listing47.html">/Clippings/ScaleAndRotate.c/Step3.txt</option>
<option value="listing48.html">/Clippings/ScaleAndRotate.c/Step5.txt</option>
<option value="listing49.html">/Completed Lab/AlphaCompositing.c</option>
<option value="listing50.html">/Completed Lab/DrawImage.c</option>
<option value="listing51.html">/Completed Lab/FilterExport.c</option>
<option value="listing52.html">/Completed Lab/GettingMoreInfo.c</option>
<option value="listing53.html">/Completed Lab/ImagesFromURL.c</option>
<option value="listing54.html">/Completed Lab/MovieToImages.c</option>
<option value="listing55.html">/Completed Lab/MultipleImages.c</option>
<option value="listing56.html">/Completed Lab/ScaleAndRotate.c</option>
<option value="listing57.html">/MacShell/all.h</option>
<option value="listing58.html">/MacShell/ImagesFromURL.r</option>
<option value="listing59.html">/MacShell/MacShell.c</option>
<option value="listing60.html">/MacShell/MacShell.h</option>
<option value="listing61.html">/MacShell/MacShell.r</option>
<option value="listing62.html">/MacShell/NavFile.c</option>
<option value="listing63.html">/MacShell/plist:carb.r</option>
<option value="listing64.html">/MacShell/sample1.h</option>
<option value="listing65.html">/MacShell/sample2.h</option>
<option value="listing66.html">/MacShell/sample3.h</option>
<option value="listing67.html">/MacShell/sample4.h</option>
<option value="listing68.html">/MacShell/sample5.h</option>
<option value="listing69.html">/MacShell/sample6.h</option>
<option value="listing70.html">/MacShell/sample7.h</option>
<option value="listing71.html">/MacShell/sample8.h</option>
<option value="listing72.html">/Start Code/AlphaCompositing.c</option>
<option value="listing73.html">/Start Code/DrawImage.c</option>
<option value="listing74.html">/Start Code/FilterExport.c</option>
<option value="listing75.html">/Start Code/GettingMoreInfo.c</option>
<option value="listing76.html">/Start Code/ImagesFromURL.c</option>
<option value="listing77.html">/Start Code/MovieToImages.c</option>
<option value="listing78.html">/Start Code/MultipleImages.c</option>
<option value="listing79.html">/Start Code/ScaleAndRotate.c</option></select>
</p>
</form>
<p><strong><a href="Graphic_Import-Export.zip">Download Sample</a></strong> (“Graphic_Import-Export.zip”, 3.63M)<BR>
<strong><a href="Graphic_Import-Export.dmg">Download Sample</a></strong> (“Graphic_Import-Export.dmg”, 4.04M)</p>
<!--
<p><strong><a href="#">Download Sample</a></strong> (“filename.sit”, 500K)</p>
-->
</td>
</tr>
<tr>
<td scope="row"><img width="680" height="10" src="images/1dot.gif" alt=""><br>
<img height="1" width="680" src="images/1dot_919699.gif" alt=""><br>
<img width="680" height="20" src="images/1dot.gif" alt=""></td>
</tr>
<tr>
<td scope="row">
<!--googleon: index -->
<pre class="sourcecodebox">// Graphics Importer and Exporter Samples// This example demonstrates how to extract image information// using Graphics Importers// Originally written by Sam Bushell for QuickTime "Live" '99// WWDC 2000 Introduction to QuickTime// Note: This application uses standard output (and SIOUX on the Mac)#include "MacShell.h"#ifndef __APPLE_CC__ #include <SIOUX.h> #include <Console.h> #include <stdio.h>#endifvoid GetMoreInfo( void ){ OSErr err = noErr; Handle hOpenTypeList = NewHandle(0); long numTypes = 0; FSSpec theFSSpec; GraphicsImportComponent importer = 0; Str31 name; OSType udType; short count, i; Handle h = NULL; Ptr p; char nul = 0;// Insert Variables.clp here... MatrixRecord defaultMatrix; RGBColor defaultOpColor; Rect defaultSourceRect; Handle colorSyncProfile = NULL; RgnHandle defaultClip = NULL; long defaultGraphicsMode; short drawsAllPixels; #ifndef __APPLE_CC__ SIOUXSettings.standalone = false; SIOUXSettings.initializeTB = false; SIOUXSettings.setupmenus = false; SIOUXSettings.autocloseonquit = true; SIOUXSettings.asktosaveonclose = false; SIOUXSetTitle( "\pGet More Info" );#endif printf( "Choose an image file...\n\n" ); BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); HLock( hOpenTypeList ); // prompt for an image file. err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); DisposeHandle( hOpenTypeList ); if (err) return; // locate and open a graphics importer component err = GetGraphicsImporterForFile( &theFSSpec, &importer ); // get the file's image description.// Step 1. Insert GetImageDescription.clp here... if( desc && *desc ) { // print basic statistics from the image description. printf( "Image width: %d\n", (*desc)->width ); printf( "Image height: %d\n", (*desc)->height ); printf( "Depth: %d\n", (*desc)->depth ); BlockMoveData( (*desc)->name, name, sizeof(name) ); CopyPascalStringToC(name, (char *)name); printf( "Format: %s\n", name); printf( "Resolution: %.1f x %.1f dpi\n", Fix2X((*desc)->hRes), Fix2X((*desc)->vRes) ); // an image description may contain a CLUT (Color Look Up Table) if( ((*desc)->depth < 16) || ((*desc)->depth > 32) ) { // get the CTable from the image description// Step 2. Insert CTable.clp here... if( colorTable ) { printf( "\nImage has a color table.\n" ); DisposeCTable( colorTable ); } } } // NOTE: GraphicsImportGetNaturalBounds() is just shorthand that builds a // rectangle from the image description's width and height. // get and print out the file's metadata // create a new user data structure // Step 3. Insert NewUserData.clp here... // extract metadata from an image and add it to an already alocated user data structure// Step 4. Insert GetMetaData.clp here... h = NewHandle(0); // retrieve the first user data type from the user data list// Step 5. Insert GetNextUserDataType.clp here... if( 0 != udType ) { printf( "\nMeta-data:\n" ); do { // determine the number of items of a given type in a user data list count = CountUserDataType( userData, udType ); for( i = 1; i <= count; i++ ) { // if the first letter of udType is 0xA9, the copyright symbol, // then use GetUserDataText instead of GetUserData // there's a list of interesting user data types in <Movies.h> if( (udType>>24) == 0xA9 ) { // retrieve language-tagged text from an item err = GetUserDataText( userData, // user data list h, // handle to recieve the data udType, // user item's type value i, // item's index value langEnglish ); // language code of text to be retrieved // nul-terminate the string in the handle. PtrAndHand( &nul, h, 1 ); // turn any CRs into spaces (to work around SIOUX behavior). p = *h; while( *p ) { if( *p == 13 ) *p = ' '; p++; }; HLock( h ); printf( " %c%c%c%c: %s\n", (char)(udType>>24), (char)(udType>>16), (char)(udType>>8), (char)udType, *h ); HUnlock( h ); } else { // get a specified user data item err = GetUserData( userData, // user data list h, // handle to recieve the data udType, // user item's type value i ); // item's index value printf( " %c%c%c%c: [%d bytes]\n", (char)(udType>>24), (char)(udType>>16), (char)(udType>>8), (char)udType, GetHandleSize(h) ); } } // retrieve the next user data type from the user data list udType = GetNextUserDataType( userData, udType ); } while( 0 != udType ); } DisposeUserData( userData ); DisposeHandle( h ); printf( "\n" ); // print out some more esoteric properties// Insert Step6.clp here... // might this image have holes? drawsAllPixels = graphicsImporterDrawsAllPixels; // find out if the graphics importer expects to draw every pixel // as some image file formats permit non-rectangular images or images // with transparent regions when such an image is drawn, not every // pixel in the boundary rectangle will be changed // ignore any error// Step 7. Insert DoesDrawAllPixels.clp here... switch( drawsAllPixels ) { case graphicsImporterDrawsAllPixels: printf( "Image will overwrite every pixel in its DestRect.\n" ); break; case graphicsImporterDoesntDrawAllPixels: printf( "Image will not overwrite every pixel in its DestRect.\n" ); break; case graphicsImporterDontKnowIfDrawAllPixels: printf( "Image may or may not overwrite every pixel in its DestRect.\n" ); break; } // Note: In a multiple-image file, the image description, metadata, // default settings, etc. can be different for each image. CloseComponent( importer ); DisposeHandle( (Handle)desc ); if( defaultClip ) DisposeRgn( defaultClip ); DisposeHandle( colorSyncProfile ); pause();}</pre>
<!--googleoff: index -->
</td>
</tr>
</table>
<!-- END WIDE COLUMN -->
<!-- END MAIN CONTENT -->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div style="width: 100%; height: 1px; background-color: #919699; margin-top: 5px; margin-bottom: 15px"></div></td>
</tr>
<tr>
<td align="center"><br/>
<table border="0" cellpadding="0" cellspacing="0" class="graybox">
<tr>
<th>Did this document help you?</th>
</tr>
<tr>
<td>
<div style="margin-bottom: 8px"><a href="http://developer.apple.com/feedback/?v=1&url=/samplecode/Graphic_Import-Export/listing75.html%3Fid%3DDTS10001037-1.0&media=dvd" target=_new>Yes</a>: Tell us what works for you.</div>
<div style="margin-bottom: 8px"><a href="http://developer.apple.com/feedback/?v=2&url=/samplecode/Graphic_Import-Export/listing75.html%3Fid%3DDTS10001037-1.0&media=dvd" target=_new>It’s good, but:</a> Report typos, inaccuracies, and so forth.</div>
<div><a href="http://developer.apple.com/feedback/?v=3&url=/samplecode/Graphic_Import-Export/listing75.html%3Fid%3DDTS10001037-1.0&media=dvd" target=_new>It wasn’t helpful</a>: Tell us what would have helped.</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- START BOTTOM APPLE NAVIGATION -->
<!--#include virtual="/includes/footer"-->
<!-- END BOTTOM APPLE NAVIGATION -->
<!-- START CENTER CLOSE -->
</center>
<!-- END CENTER CLOSE -->
</body>
</html>