forked from cellularmitosis/ADC-reference-library-2009-july
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisting74.html
executable file
·430 lines (362 loc) · 18.4 KB
/
listing74.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/FilterExport.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/FilterExport.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 adding a filter effect to the image and// using a Graphics Exporter component to export the image as// a PNG image.// Originally written by Sam Bushell for QuickTime "Live" '99// WWDC 2000 Introduction to QuickTime#include "MacShell.h"//----------static pascal Boolean theRequestSettingsFilter( DialogRef inDialog, EventRecord *ioEvent, short *outItemHit, void *inDataPtr );static pascal Boolean theRequestSettingsFilter( DialogRef inDialog, EventRecord *ioEvent, short *outItemHit, void *inDataPtr ){#pragma unused( outItemHit ) WindowRef eventWindow; Boolean result = false; PixMapHandle hPixMap = GetGWorldPixMap(static_cast<GWorldPtr>(inDataPtr)); // static_cast for GCC if (ioEvent->what == updateEvt) { eventWindow = (WindowRef)(ioEvent->message); if (eventWindow != GetDialogWindow( inDialog )) { // blit the image to the screen CopyBits(GetPortBitMapForCopyBits(static_cast<CGrafPtr>(inDataPtr)), GetPortBitMapForCopyBits(GetWindowPort(eventWindow)), &(*hPixMap)->bounds, &(*hPixMap)->bounds, ditherCopy, NULL); result = true; } } return result;}void FilterExport( void ){ OSErr err = noErr; Handle hOpenTypeList = NewHandle(0); long numTypes = 0; FSSpec theFSSpec; Boolean isSelected, isReplacing; GraphicsImportComponent importer = 0; Rect naturalBounds, windowBounds; WindowPtr window = NULL; GWorldPtr sourceGWorld = NULL; ImageDescriptionHandle offscreenDesc = NULL; GWorldPtr destGWorld = NULL; MatrixRecord matrix; ImageSequence imageSequence = 0; QTAtomContainer videoFilter = 0; QTAtomContainer videoFilterList = 0; ImageDescriptionHandle effectDesc = NULL; ImageSequenceDataSource effectDataSource = 0; QTParameterDialog dialog = NULL; QTParamPreviewRecord previewParameter = {0, NULL}; // sourceID, picHandle long aLong; QTAtom effectTypeAtom; OSType effectType; GraphicsExportComponent exporter = 0; BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); HLock( hOpenTypeList ); 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 native size of the image associated with the importer err = GraphicsImportGetNaturalBounds( importer, &naturalBounds ); windowBounds = naturalBounds; OffsetRect( &windowBounds, 10, 45 ); window = NewCWindow( NULL, &windowBounds, "\pFilter Export ", true, documentProc, (WindowPtr)-1, true, 0); SetPortWindowPort( window ); // draw the image into an offscreen GWorld// Step 1. Insert Step1.clp here... pause(); // allocate a second offscreen GWorld to draw the filtered image into err = QTNewGWorld( &destGWorld, k32ARGBPixelFormat, &naturalBounds, NULL, NULL, kICMTempThenAppMemory ); LockPixels( GetGWorldPixMap( destGWorld ) ); // ask for a list of all the single source effects (ie, filters) // this function returns a QTAtomContainer holding a list of the currently installed effects components// Step 2. Insert QTGetEffectsList.clp here... // prompt for the user to select a filter // create a new atom container to build the effect// Step 3. Insert QTNewAtomContainer.clp here... // create the effect dialog box; choose an effect from the list of effects passed to the function // standard dialog includes a preview of the effect// Step 4. Insert StandardParameterDialog.clp here... // parse the effect sample to find out what kind of effect it was// Step 5. Insert QTFindChildByIndex.clp here... // copy the effect type from the effectType atom -- ie. Blur effect is type 'blur' // Step 6. Insert QTCopyAtomDataToPtr.clp here... // cross platform friendly effectType = EndianU32_BtoN(effectType); // add a source label to the effect sample aLong = EndianU32_BtoN('srca');// Step 7. Insert QTInsertChild.clp here... HLockHi(videoFilter);// Step 8. Insert Step8.clp here // blit the now filtered image to the screen CopyBits(GetPortBitMapForCopyBits(destGWorld), GetPortBitMapForCopyBits(GetWindowPort(window)), &naturalBounds, &naturalBounds, ditherCopy, NULL); pause(); // write the filtered image out as a PNG file. err = PutFile( "\pSave the filtered image:", "\pfiltered.png", &theFSSpec, &isSelected, &isReplacing); if (err) goto bail; // find and open the PNG Graphics Exporter component// Step 9. Insert OpenADefaultComponent.clp here... // set the input for the graphics exporter err = GraphicsExportSetInputGWorld( exporter, // component instance destGWorld ); // input source // set the destination for the export // Step 10. Insert SetOutputFile.clp here... // the depth to use for the exported image// Step 11. Insert SetDepth.clp here... // do the export// Step 12. Insert DoExport.clp here... // blit the image to the screen CopyBits(GetPortBitMapForCopyBits(destGWorld), GetPortBitMapForCopyBits(GetWindowPort(window)), &naturalBounds, &naturalBounds, ditherCopy, NULL); CloseComponent ( exporter ); pause(); // write out the image again as a .jpg using the settings dialog OpenADefaultComponent( GraphicsExporterComponentType, kQTFileTypeJPEG, &exporter ); // does the export component supports the exporter setting dialog? if ( CallComponentCanDo( exporter , kGraphicsExportRequestSettingsSelect )) { // set the input for the graphics exporter err = GraphicsExportSetInputGWorld( exporter, // component instance destGWorld ); // input source // get the settings using the settings dialog err = GraphicsExportRequestSettings( exporter, NewModalFilterYDUPP( theRequestSettingsFilter ), destGWorld ); err = PutFile( "\pSave the filtered image:", "\pfiltered.jpg", &theFSSpec, &isSelected, &isReplacing); if (err) goto bail; // set the destination for the export err = GraphicsExportSetOutputFile( exporter, &theFSSpec ); // export destination // do the export err = GraphicsExportDoExport( exporter, NULL ); // actual size written; NULL to ignore } // blit the image to the screen CopyBits(GetPortBitMapForCopyBits(destGWorld), GetPortBitMapForCopyBits(GetWindowPort(window)), &naturalBounds, &naturalBounds, ditherCopy, NULL); bail: // clean up if ( imageSequence ) CDSequenceEnd( imageSequence ); if ( videoFilter ) QTDisposeAtomContainer( videoFilter ); if ( videoFilterList ) QTDisposeAtomContainer( videoFilterList ); if ( offscreenDesc) DisposeHandle( (Handle)offscreenDesc ); if ( effectDesc ) DisposeHandle( (Handle)effectDesc ); if ( importer ) CloseComponent( importer ); if ( exporter ) CloseComponent( exporter ); if ( sourceGWorld ) DisposeGWorld( sourceGWorld ); if ( destGWorld ) DisposeGWorld( destGWorld ); if ( previewParameter.sourcePicture ) KillPicture( previewParameter.sourcePicture );}</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/listing74.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/listing74.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/listing74.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>