forked from cellularmitosis/ADC-reference-library-2009-july
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisting79.html
executable file
·306 lines (272 loc) · 13.8 KB
/
listing79.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/ScaleAndRotate.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/ScaleAndRotate.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 uses graphics importers to draw an image// then demonstrates how to perform scaling, rotation and perspective// manipulation using matrix operations// Originally written by Sam Bushell for QuickTime "Live" '99// WWDC 2000 Introduction to QuickTime#include "MacShell.h"void ScaleAndRotate( void ){ OSErr err = noErr; Handle hOpenTypeList = NewHandle(0); long numTypes = 0; FSSpec theFSSpec; GraphicsImportComponent importer = 0; Rect naturalBounds, windowBounds, scaledBounds; WindowPtr window = NULL; MatrixRecord matrix; Fixed naturalWidth, naturalHeight; FixedPoint fromQuad[4], toQuad[4]; BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); HLock( hOpenTypeList ); err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); DisposeHandle( hOpenTypeList ); if ( err ) return;// Step 1. Insert Step1.clp here... pause(); // scale the image by a factor of 2x. // the top-left coordinate of an image's natural bounds is always (0,0). scaledBounds = naturalBounds; scaledBounds.right = scaledBounds.right * 2; scaledBounds.bottom = scaledBounds.bottom * 2; // define the rectangle in which to draw an image// Step 2. Insert SetBoundsRect.clp here... // resize the window to fit, and redraw.// Step 3. Insert Step3.clp here... pause(); // rotate the image ninety degrees clockwise// Step 4. Insert Rotate.clp here... // resize the window to fit, and redraw. // get the new bounds rect, size the window then draw// Step 5. Insert Step5.clp here... pause(); // give the image some hefty perspective. // set up two quadrilateral coordinates and create a translation matrix // from one to the other using QuadToQuadMatrix() // QuadToQuadMatrix was added in QuickTime 4.0. naturalWidth = Long2Fix( naturalBounds.right ); naturalHeight = Long2Fix( naturalBounds.bottom ); fromQuad[0].x = 0; fromQuad[0].y = 0; fromQuad[1].x = naturalWidth; fromQuad[1].y = 0; fromQuad[2].x = naturalWidth; fromQuad[2].y = naturalHeight; fromQuad[3].x = 0; fromQuad[3].y = naturalHeight; toQuad[0].x = naturalWidth/8; toQuad[0].y = naturalHeight/4; toQuad[1].x = naturalWidth*9/8; toQuad[1].y = 0; toQuad[2].x = naturalWidth; toQuad[2].y = naturalHeight*6/4; toQuad[3].x = 0; toQuad[3].y = naturalHeight; SetIdentityMatrix( &matrix ); QuadToQuadMatrix( (Fixed *)fromQuad, (Fixed *)toQuad, &matrix ); err = GraphicsImportSetMatrix( importer, &matrix ); // resize the window to fit, and redraw // get the new bounds rect, size the window then draw err = GraphicsImportGetBoundsRect( importer, &scaledBounds ); SizeWindow( window, scaledBounds.right, scaledBounds.bottom, false ); SetPortWindowPort( window ); EraseRect( &scaledBounds ); err = GraphicsImportDraw( importer ); CloseComponent( importer );}</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/listing79.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/listing79.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/listing79.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>