comparison plugins/crazychat/camdata.c @ 11232:8bcd4d4ccef6

[gaim-migrate @ 13372] committing crazychat again. hopefully here to stay. committer: Tailor Script <tailor@pidgin.im>
author Charlie Stockman <chuckleberry>
date Thu, 11 Aug 2005 07:56:29 +0000
parents ed017b9c532d
children
comparison
equal deleted inserted replaced
11231:64e2c65ef650 11232:8bcd4d4ccef6
1 /*
2 * camdata.c
3 * basecame
4 *
5 * Created by CS194 on Mon Apr 26 2004.
6 * Copyright (c) 2004 __MyCompanyName__. All rights reserved.
7 *
8 */
9
10 #include "camdata.h"
11 //#include "AppBlit_Component.h"
12 #include "QTUtilities.h"
13 #include "Utilities.h"
14
15
16 #define BailNULL(n) if (!n) goto bail;
17 #define BailError(n) if (n) goto bail;
18 #define BailNil(n) if (!n) goto bail;
19 #define BailErr(x) {if (x != noErr) goto bail;}
20 #define bitdepth 32
21
22 mungDataPtr myMungData = NULL;
23 long mWorlds[20];
24 UInt32 mRedCount[256], mGreenCound[256], mBlueCount[256];
25
26 static void DecompressSequencePreflight(GWorldPtr srcGWorld,
27 ImageSequence *imageSeq,
28 GWorldPtr destGWorld,
29 Rect *srcRect);
30 //static void DrawRGBHistogram(mungDataRecord *theMungData);
31 //static void CreateEffectDescription(mungDataRecord *theMungData);
32 //static void CreateEffectDecompSequence(mungDataRecord *theMungData);
33 //static void AddGWorldDataSourceToEffectDecompSeq(mungDataRecord *theMungData);
34 //static void MakeEffectTimeBaseForEffect(mungDataRecord *theMungData);
35 //static void DrawUsingEffect(mungDataRecord *theMungData);
36
37
38 OSErr InitializeMungData(Rect bounds)
39 {
40 OSErr err = noErr;
41
42 if(myMungData)
43 {
44 DisposeMungData();
45 }
46
47 myMungData = (mungDataPtr)NewPtrClear(sizeof(mungDataRecord));
48 if (myMungData == nil)
49 {
50 err = MemError();
51 goto bail;
52 }
53
54 myMungData->effect = 0; // always
55
56
57 BailErr(QTNewGWorld(&(myMungData->gw),bitdepth,&bounds,0,0,0));
58 LockPixels(GetGWorldPixMap(myMungData->gw));
59
60 SetMungDataColorDefaults();
61
62
63
64 myMungData->selectedIndex = 0;
65 myMungData->overlay = NULL;
66
67 SetCurrentClamp(-1);
68
69
70
71 myMungData->bounds = bounds;
72
73 SetRect(&bounds, 0, 0, 256*2+4, 128*3 + 20);
74 BailErr(QTNewGWorld(&(myMungData->histoWorld),bitdepth,&bounds,0,0,0));
75 LockPixels(GetGWorldPixMap(myMungData->histoWorld));
76
77 bail:
78 return err;
79 }
80
81 OSErr DisposeMungData(void)
82 { // check this out
83 OSErr err = noErr;
84
85 if(myMungData)
86 {
87 //if(myMungData->drawSeq)
88 //{
89 // CDSequenceEnd(myMungData->drawSeq);
90 //}
91
92 if(myMungData->gw)
93 {
94 DisposeGWorld(myMungData->gw);
95 myMungData->gw = nil;
96 }
97
98 if(myMungData->overlay)
99 {
100 DisposeGWorld(myMungData->overlay);
101 myMungData->overlay = nil;
102 }
103
104 if(myMungData->histoWorld)
105 {
106 DisposeGWorld(myMungData->histoWorld);
107 myMungData->histoWorld = nil;
108 }
109
110 if (myMungData->effectTimeBase)
111 {
112 DisposeTimeBase(myMungData->effectTimeBase);
113 }
114 if (myMungData->effectParams)
115 {
116 QTDisposeAtomContainer(myMungData->effectParams);
117 }
118 if (myMungData->effectDesc)
119 {
120 DisposeHandle((Handle)myMungData->effectDesc);
121 }
122
123 DisposePtr((Ptr)myMungData);
124 myMungData = nil;
125 }
126 return err;
127 }
128
129 static void DecompressSequencePreflight(GWorldPtr srcGWorld,
130 ImageSequence *imageSeq,
131 GWorldPtr destGWorld,
132 Rect *srcRect)
133 // might not need this one
134
135 {
136 ImageDescriptionHandle imageDesc = nil;
137
138 BailErr(MakeImageDescriptionForPixMap (GetGWorldPixMap(srcGWorld), &imageDesc));
139
140 // use our built-in decompressor to draw
141 // (**imageDesc).cType = kCustomDecompressorType;
142
143 // *********** MIGHT BE MAKING A BIG MISTAKE ******************
144 // pass a compressed sample so a codec can perform preflighting before the first DecompressSequenceFrameWhen call
145
146 BailErr(DecompressSequenceBegin(imageSeq,
147 imageDesc,
148 destGWorld,
149 0,
150 srcRect,
151 nil,
152 srcCopy,
153 nil,
154 0,
155 codecNormalQuality,
156 bestSpeedCodec));
157
158 bail:
159 if (imageDesc)
160 {
161 DisposeHandle((Handle)imageDesc);
162 }
163 }
164
165 ImageSequence GetMungDataDrawSeq()
166 {
167 return myMungData->drawSeq;
168 }
169
170 void SetMungDataColorDefaults()
171 {
172 if(myMungData)
173 {
174 myMungData->redMin = 2;
175 myMungData->redMax = 254;
176 myMungData->greenMin = 2;
177 myMungData->greenMax = 254;
178 myMungData->blueMin = 2;
179 myMungData->blueMax = 254;
180 }
181 }
182
183 void GetMungDataBoundsRect(Rect *boundsRect)
184 // might not need this one
185 {
186 MacSetRect (boundsRect,
187 myMungData->bounds.left,
188 myMungData->bounds.top,
189 myMungData->bounds.right,
190 myMungData->bounds.bottom
191 );
192 }
193
194 void SetCurrentClamp(short index) // :crazy:20040426
195 {
196 myMungData->selectedIndex = index;
197 }
198
199 GWorldPtr GetMungDataOffscreen()
200 {
201 return (myMungData->gw);
202 }
203
204 void SetMungDataDrawSeq(ImageSequence theDrawSeq)
205 {
206 myMungData->drawSeq = theDrawSeq;
207 }
208
209
210 CGrafPtr GetMungDataWindowPort()
211 {
212 return GetWindowPort(myMungData->window);
213 }