-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.cpp
362 lines (299 loc) · 9.6 KB
/
Main.cpp
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// ============================================================================
//
// This file are where the Conditions/Actions/Expressions are defined.
// You can manually enter these, or use CICK (recommended)
// See the Extension FAQ in this SDK for more info and where to download it
//
// ============================================================================
// Common Include
#include "common.h"
int resizePerspective(LPRDATA rdPtr, int oldsize);
// Quick memo: content of the eventInformations arrays
// ---------------------------------------------------
// Menu ID
// String ID
// Code
// Flags
// Number_of_parameters
// Parameter_type [Number_of_parameters]
// Parameter_TitleString [Number_of_parameters]
// Definitions of parameters for each condition
short conditionsInfos[]=
{
0 };
// Definitions of parameters for each action
short actionsInfos[]=
{
AID_actSetZoomValue, AID_actSetZoomValue, 0, 0, 1, PARAM_EXPRESSION, AP0ID_actSetZoomValue,
AID_actSetPanorama, AID_actSetPanorama, 1, 0, 0,
AID_actSetPerspective, AID_actSetPerspective, 2, 0, 0,
AID_actSetSineWave, AID_actSetSineWave, 3, 0, 0,
AID_actSetCustom, AID_actSetCustom, 4, 0, 0,
AID_actSetNumWaves, AID_actSetNumWaves, 5, 0, 1, PARAM_EXPRESSION, AP0ID_actSetNumWaves,
AID_actSetOffset, AID_actSetOffset, 6, 0, 1, PARAM_EXPRESSION, AP0ID_actSetOffset,
AID_actSetHorizontal, AID_actSetHorizontal, 7, 0, 0,
AID_actSetVertical, AID_actSetVertical, 8, 0, 0,
AID_actSetLeftTop, AID_actSetLeftTop, 9, 0, 0,
AID_actSetRightBottom, AID_actSetRightBottom, 10, 0, 0,
AID_actSetCustomValue, AID_actSetCustomValue, 11, 0, 2, PARAM_EXPRESSION, PARAM_EXPRESSION, AP0ID_actSetCustomValue, AP1ID_actSetCustomValue,
AID_actSetWidth, AID_actSetWidth, 12, 0, 1, PARAM_EXPRESSION, AP0ID_actSetWidth,
AID_actSetHeight, AID_actSetHeight, 13, 0, 1, PARAM_EXPRESSION, AP0ID_actSetHeight,
AID_actSetResampleOn, AID_actSetResampleOn, 14, 0, 0,
AID_actSetResampleOff, AID_actSetResampleOff, 15, 0, 0,
AID_actSetSineOffset, AID_actSetSineOffset, 16, 0, 0,
AID_actSetCustomOffset, AID_actSetCustomOffset, 17, 0, 0,
0 };
// Definitions of parameters for each expression
short expressionsInfos[]=
{
EID_expGetZoomValue, EID_expGetZoomValue, 0, 0, 0,
EID_expGetOffset, EID_expGetOffset, 1, 0, 0,
EID_expNumWaves, EID_expNumWaves, 2, 0, 0,
EID_expGetCustom, EID_expGetCustom, 3, 0, 1, EXPPARAM_LONG, 0,
EID_expGetWidth, EID_expGetWidth, 4, 0, 0,
EID_expGetHeight, EID_expGetHeight, 5, 0, 0,
0 };
// ============================================================================
//
// CONDITION ROUTINES
//
// ============================================================================
// ============================================================================
//
// ACTIONS ROUTINES
//
// ============================================================================
short WINAPI DLLExport actSetZoomValue(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->ZoomValue = param1;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetPanorama(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Effect = PANORAMA;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetPerspective(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Effect = PERSPECTIVE;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetSineWave(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Effect = SINEWAVE;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetCustom(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Effect = CUSTOM;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetSineOffset(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Effect = SINEOFFSET;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetCustomOffset(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Effect = CUSTOMOFFSET;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetNumWaves(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->SineWaveWaves = param1;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetOffset(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->Offset = param1;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetHorizontal(LPRDATA rdPtr, long param1, long param2)
{
int OldSize = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
int NewSize = rdPtr->rHo.hoImgWidth;
rdPtr->Direction = HORIZONTAL;
rdPtr->roc.rcChanged = true;
int MinSize = min(OldSize,NewSize);
int * NewCustom = new int[NewSize];
memset(NewCustom,0,NewSize*sizeof(int));
for(int i=0; i<MinSize; i++)
NewCustom[i] = rdPtr->CustomArray[i];
delete[] rdPtr->CustomArray;
rdPtr->CustomArray = NewCustom;
return 0;
}
short WINAPI DLLExport actSetVertical(LPRDATA rdPtr, long param1, long param2)
{
int OldSize = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
int NewSize = rdPtr->rHo.hoImgHeight;
rdPtr->Direction = VERTICAL;
rdPtr->roc.rcChanged = true;
int MinSize = min(OldSize,NewSize);
int * NewCustom = new int[NewSize];
memset(NewCustom,0,NewSize*sizeof(int));
for(int i=0; i<MinSize; i++)
NewCustom[i] = rdPtr->CustomArray[i];
delete[] rdPtr->CustomArray;
rdPtr->CustomArray = NewCustom;
return 0;
}
short WINAPI DLLExport actSetLeftTop(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->PerspectiveDir = 0;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetRightBottom(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->PerspectiveDir = 1;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetCustomValue(LPRDATA rdPtr, long param1, long param2)
{
int size = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
if(param1 >= 0 && param1 < size)
rdPtr->CustomArray[param1] = param2;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetWidth(LPRDATA rdPtr, long param1, long param2)
{
int oldSize = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
rdPtr->rHo.hoImgWidth = param1;
return resizePerspective(rdPtr, oldSize);
}
short WINAPI DLLExport actSetHeight(LPRDATA rdPtr, long param1, long param2)
{
int oldSize = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
rdPtr->rHo.hoImgHeight = param1;
return resizePerspective(rdPtr, oldSize);
}
int resizePerspective(LPRDATA rdPtr, int oldsize){
//Recreate temp-image
/* rdPtr->TempImage->Delete();
fprh rhPtr = rdPtr->rHo.hoAdRunHeader;
LPSURFACE ps = WinGetSurface((int)rhPtr->rhIdEditWin);
LPSURFACE pProto = NULL;
if ( GetSurfacePrototype(&pProto, ps->GetDepth(), ST_MEMORY, SD_DIB) ){
rdPtr->TempImage->Create(rdPtr->rHo.hoImgWidth, rdPtr->rHo.hoImgHeight, pProto);
if( !rdPtr->TempImage->IsValid() )
{return -1;}
} */
// Delete temp image so that it's automatically recreated with the correct size
if ( rdPtr->TempImage != NULL )
{
delete rdPtr->TempImage;
rdPtr->TempImage = NULL;
}
//Recreate temp-array
int size = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
int * newArray = new int[size];
int numNewInts = min(size,oldsize);
for(int i=0;i<size;i++){
if(i<numNewInts)
newArray[i] = rdPtr->CustomArray[i];
else
newArray[i] = 0;
}
delete [] rdPtr->CustomArray;
rdPtr->CustomArray = newArray;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetResampleOn(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->resample = true;
rdPtr->roc.rcChanged = true;
return 0;
}
short WINAPI DLLExport actSetResampleOff(LPRDATA rdPtr, long param1, long param2)
{
rdPtr->resample = false;
rdPtr->roc.rcChanged = true;
return 0;
}
// ============================================================================
//
// EXPRESSIONS ROUTINES
//
// ============================================================================
long WINAPI DLLExport expGetZoomValue(LPRDATA rdPtr, long param1)
{
return rdPtr->ZoomValue;
}
long WINAPI DLLExport expGetOffset(LPRDATA rdPtr, long param1)
{
return rdPtr->Offset;
}
long WINAPI DLLExport expNumWaves(LPRDATA rdPtr, long param1)
{
return rdPtr->SineWaveWaves;
}
long WINAPI DLLExport expGetCustom(LPRDATA rdPtr, long param1)
{
long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
int size = (rdPtr->Direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : rdPtr->rHo.hoImgHeight;
return rdPtr->CustomArray[min(max(0,p1),size-1)];
}
long WINAPI DLLExport expGetWidth(LPRDATA rdPtr, long param1)
{
return rdPtr->rHo.hoImgWidth;
}
long WINAPI DLLExport expGetHeight(LPRDATA rdPtr, long param1)
{
return rdPtr->rHo.hoImgHeight;
}
// ----------------------------------------------------------
// Condition / Action / Expression jump table
// ----------------------------------------------------------
// Contains the address inside the extension of the different
// routines that handle the action, conditions and expressions.
// Located at the end of the source for convinience
// Must finish with a 0
//
long (WINAPI * ConditionJumps[])(LPRDATA rdPtr, long param1, long param2) =
{
0};
short (WINAPI * ActionJumps[])(LPRDATA rdPtr, long param1, long param2) =
{
actSetZoomValue,
actSetPanorama,
actSetPerspective,
actSetSineWave,
actSetCustom,
actSetNumWaves,
actSetOffset,
actSetHorizontal,
actSetVertical,
actSetLeftTop,
actSetRightBottom,
actSetCustomValue,
actSetWidth,
actSetHeight,
actSetResampleOn,
actSetResampleOff,
actSetSineOffset,
actSetCustomOffset,
0
};
long (WINAPI * ExpressionJumps[])(LPRDATA rdPtr, long param) =
{
expGetZoomValue,
expGetOffset,
expNumWaves,
expGetCustom,
expGetWidth,
expGetHeight,
0
};