-
Notifications
You must be signed in to change notification settings - Fork 3
/
listing49.html
executable file
·318 lines (281 loc) · 15.2 KB
/
listing49.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 - /Completed Lab/AlphaCompositing.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>/Completed Lab/AlphaCompositing.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 takes two images and composites them together// demonstrating the use of different graphic modes// Originally written by Sam Bushell for QuickTime "Live" '99// WWDC 2000 Introduction to QuickTime#include "MacShell.h"void AlphaComposite( void ){ OSErr err = noErr; Handle hOpenTypeList = NewHandle(0); long numTypes = 0; FSSpec theFSSpec; GraphicsImportComponent backgroundImporter = 0, foregroundImporter = 0; Rect backgroundBounds, windowBounds, foregroundBounds; WindowPtr window = NULL; MatrixRecord matrix; RGBColor whiteColor; FixedPoint backgroundCenter; BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); HLock( hOpenTypeList ); // prompt for a background image. err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); if (err) goto bail; err = GetGraphicsImporterForFile( &theFSSpec, &backgroundImporter ); // prompt for a foreground image. err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); if (err) goto bail; err = GetGraphicsImporterForFile( &theFSSpec, &foregroundImporter ); err = GraphicsImportGetNaturalBounds( backgroundImporter, &backgroundBounds ); windowBounds = backgroundBounds; OffsetRect( &windowBounds, 10, 45 ); window = NewCWindow( NULL, &windowBounds, "\pAlpha Composite", true, documentProc, (WindowPtr)-1, true, 0); // set the graphics port for drawing the first image err = GraphicsImportSetGWorld( backgroundImporter, GetWindowPort( window ), NULL ); // draw the background err = GraphicsImportDraw( backgroundImporter ); pause(); // center the foreground image over the background image // get the native size of the foreground image // offset the image to center it // set the rectangle in which to draw an image err = GraphicsImportGetNaturalBounds( foregroundImporter, &foregroundBounds ); OffsetRect( &foregroundBounds, (backgroundBounds.right - foregroundBounds.right) / 2, (backgroundBounds.bottom - foregroundBounds.bottom) / 2 ); err = GraphicsImportSetBoundsRect( foregroundImporter, &foregroundBounds ); // draw the foreground image over the background image, // using the default graphics mode, ditherCopy. err = GraphicsImportSetGWorld( foregroundImporter, GetWindowPort( window ), NULL ); err = GraphicsImportDraw( foregroundImporter ); pause(); // redraw the background. err = GraphicsImportDraw( backgroundImporter ); // draw the foreground using the transparent graphics mode, with white transparent. whiteColor.red = 0xffff; whiteColor.green = 0xffff; whiteColor.blue = 0xffff; err = GraphicsImportSetGraphicsMode( foregroundImporter, // graphics importer instance transparent, // graphics transfer mode to use for drawing &whiteColor ); // color to use for blending and transparent operations err = GraphicsImportDraw( foregroundImporter ); pause(); // redraw the background. err = GraphicsImportDraw( backgroundImporter ); // draw the foreground using the straight alpha graphics mode. err = GraphicsImportSetGraphicsMode( foregroundImporter, // graphics importer instance graphicsModeStraightAlpha, // graphics transfer mode to use for drawing NULL ); err = GraphicsImportDraw( foregroundImporter ); pause(); // redraw the background. err = GraphicsImportDraw( backgroundImporter ); // draw the foreground *rotated 30 degrees*, using the straight alpha graphics mode. err = GraphicsImportGetMatrix( foregroundImporter, &matrix ); backgroundCenter.x = Long2Fix( backgroundBounds.right - backgroundBounds.left ) / 2; backgroundCenter.y = Long2Fix( backgroundBounds.bottom - backgroundBounds.top ) / 2; RotateMatrix( &matrix, Long2Fix(30), backgroundCenter.x, backgroundCenter.y ); err = GraphicsImportSetMatrix( foregroundImporter, &matrix ); err = GraphicsImportDraw( foregroundImporter );bail: if ( backgroundImporter ) CloseComponent( backgroundImporter ); if ( foregroundImporter ) CloseComponent( foregroundImporter ); if ( hOpenTypeList) DisposeHandle( hOpenTypeList );}</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/listing49.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/listing49.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/listing49.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>