Subversion Repositories filter_foundry

Rev

Rev 440 | Rev 456 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 440 Rev 444
Line 21... Line 21...
21
//#include <stdio.h>
21
//#include <stdio.h>
22
//#include <sound.h>
22
//#include <sound.h>
23
 
23
 
24
#include "ff.h"
24
#include "ff.h"
25
 
25
 
-
 
26
#include "str.h"
26
#include "node.h"
27
#include "node.h"
27
#include "funcs.h"
28
#include "funcs.h"
28
#include "y.tab.h"
29
#include "y.tab.h"
29
#include "scripting.h"
30
#include "scripting.h"
30
#include <math.h>
31
#include <math.h>
Line 78... Line 79...
78
        for (i = 0; i < 4; i++) hash += djb2(parm->szFormula[i]);
79
        for (i = 0; i < 4; i++) hash += djb2(parm->szFormula[i]);
79
 
80
 
80
        return hash;
81
        return hash;
81
}
82
}
82
 
83
 
83
void get_temp_afs(char *outfilename, Boolean isStandalone, PARM_T *parm) {
84
size_t get_temp_afs(LPTSTR outfilename, Boolean isStandalone, PARM_T *parm) {
84
        char* tempdir;
85
        char* atempdir;
85
        int hash;
86
        int hash;
-
 
87
        size_t i, j;
-
 
88
        TCHAR out[MAX_PATH + 1];
-
 
89
        char ahash[20];
-
 
90
 
-
 
91
        // out = getenv("TMP")
-
 
92
        atempdir = getenv("TMP");
-
 
93
        for (i = 0; i < strlen(atempdir); i++) {
-
 
94
                out[i] = (TCHAR)atempdir[i];
-
 
95
                out[i + 1] = 0;
-
 
96
        }
86
 
97
 
87
        tempdir = getenv("TMP");
-
 
88
        #ifdef WIN_ENV
98
        #ifdef WIN_ENV
89
        if (strlen(tempdir) > 0) strcat(tempdir, "\\");
99
        if (xstrlen(out) > 0) xstrcat(out, TEXT("\\"));
90
        #else
100
        #else
91
        if (strlen(tempdir) > 0) strcat(tempdir, "/");
101
        if (xstrlen(out) > 0) xstrcat(out, TEXT("/"));
92
        #endif
102
        #endif
93
 
103
 
94
        hash = (isStandalone) ? get_parm_hash(parm) : 0;
104
        hash = (isStandalone) ? get_parm_hash(parm) : 0;
-
 
105
 
95
        sprintf(outfilename, "%sFilterFoundry%d.afs", tempdir, hash);
106
        // sprintf(outfilename, "%sFilterFoundry%d.afs", atempdir, hash);
-
 
107
        xstrcat(out, TEXT("FilterFoundry"));
-
 
108
        _itoa(hash, &ahash[0], 10);
-
 
109
        for (i = 0; i < strlen(ahash); i++) {
-
 
110
                j = xstrlen(out);
-
 
111
                out[j] = (TCHAR)ahash[i];
-
 
112
                out[j + 1] = 0;
-
 
113
        }
-
 
114
        xstrcat(out, TEXT(".afs"));
-
 
115
        if (outfilename != NULL) {
-
 
116
                xstrcpy(outfilename, out);
-
 
117
        }
-
 
118
        return xstrlen(out);
96
}
119
}
97
 
120
 
98
DLLEXPORT MACPASCAL
121
DLLEXPORT MACPASCAL
99
void ENTRYPOINT(short selector, FilterRecordPtr pb, intptr_t *data, short *result){
122
void ENTRYPOINT(short selector, FilterRecordPtr pb, intptr_t *data, short *result){
100
        static Boolean wantdialog = false;
123
        static Boolean wantdialog = false;
Line 153... Line 176...
153
                // DM 19.07.2021 : Tried running the 8BF file in Adobe Premiere 5 (yes, that's possible,
176
                // DM 19.07.2021 : Tried running the 8BF file in Adobe Premiere 5 (yes, that's possible,
154
                // and there is even a FilterFactory for Premiere!),
177
                // and there is even a FilterFactory for Premiere!),
155
                // but it crashes in evalpixel() where there is write-access to the "outp".
178
                // but it crashes in evalpixel() where there is write-access to the "outp".
156
                // Probably the canvas structure is different (maybe it contains frames to achieve transitions?)
179
                // Probably the canvas structure is different (maybe it contains frames to achieve transitions?)
157
                if (!premiereWarnedOnce) {
180
                if (!premiereWarnedOnce) {
158
                        simplealert(_strdup("This version of Filter Foundry is not compatible with Adobe Premiere!"));
181
                        simplealert((TCHAR*)TEXT("This version of Filter Foundry is not compatible with Adobe Premiere!"));
159
                }
182
                }
160
                premiereWarnedOnce = true;
183
                premiereWarnedOnce = true;
161
                *result = errPlugInHostInsufficient;
184
                *result = errPlugInHostInsufficient;
162
                return;
185
                return;
163
        }
186
        }
Line 242... Line 265...
242
                        if (!gdata) break;
265
                        if (!gdata) break;
243
                        gdata->hWndMainDlg = (HWND)((PlatformData*)((AboutRecordPtr)pb)->platformData)->hwnd; // so that simplealert() works
266
                        gdata->hWndMainDlg = (HWND)((PlatformData*)((AboutRecordPtr)pb)->platformData)->hwnd; // so that simplealert() works
244
                        gdata->standalone = gdata->parmloaded = readPARMresource((HMODULE)hDllInstance,&reason);
267
                        gdata->standalone = gdata->parmloaded = readPARMresource((HMODULE)hDllInstance,&reason);
245
                        if (gdata->parmloaded && (gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) {
268
                        if (gdata->parmloaded && (gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) {
246
                                if (gdata->obfusc) {
269
                                if (gdata->obfusc) {
247
                                        simplealert(_strdup("Incompatible obfuscation."));
270
                                        simplealert((TCHAR*)TEXT("Incompatible obfuscation."));
248
                                }
271
                                }
249
                                else {
272
                                else {
250
                                        simplealert(_strdup("Invalid parameter data."));
273
                                        simplealert((TCHAR*)TEXT("Invalid parameter data."));
251
                                }
274
                                }
252
                        }
275
                        }
253
                        else {
276
                        else {
254
                                DoAbout((AboutRecordPtr)pb);
277
                                DoAbout((AboutRecordPtr)pb);
255
                        }
278
                        }
Line 291... Line 314...
291
                                           Also, all global variables are unloaded, so the plugin cannot preserve any data.
314
                                           Also, all global variables are unloaded, so the plugin cannot preserve any data.
292
                                           Workaround in FF 1.7: If the host GIMP is detected, then a special mode will be activated.
315
                                           Workaround in FF 1.7: If the host GIMP is detected, then a special mode will be activated.
293
                                           This mode saves the filter data into a temporary file "FilterFoundryXX.afs" and loads it
316
                                           This mode saves the filter data into a temporary file "FilterFoundryXX.afs" and loads it
294
                                           when the window is opened again. */
317
                                           when the window is opened again. */
295
                                        // Workaround: Save settings in "FilterFoundryXX.afs" if the host does not preserve pb->parameters
318
                                        // Workaround: Save settings in "FilterFoundryXX.afs" if the host does not preserve pb->parameters
296
                                        char outfilename[255];
319
                                        TCHAR outfilename[MAX_PATH+1];
297
                                        StandardFileReply sfr;
320
                                        StandardFileReply sfr;
298
                                        char* bakexpr[4];
321
                                        char* bakexpr[4];
299
                                        int i;
322
                                        int i;
300
 
323
 
301
                                        sfr.sfGood = true;
324
                                        sfr.sfGood = true;
302
                                        sfr.sfReplacing = true;
325
                                        sfr.sfReplacing = true;
303
                                        sfr.sfType = PS_FILTER_FILETYPE;
326
                                        sfr.sfType = PS_FILTER_FILETYPE;
304
 
327
 
305
                                        get_temp_afs(&outfilename[0], gdata->standalone, &gdata->parm);
328
                                        get_temp_afs(&outfilename[0], gdata->standalone, &gdata->parm);
306
 
329
 
307
                                        myc2pstrcpy(sfr.sfFile.name, outfilename);
330
                                        xstrcpy(sfr.sfFile.szName, outfilename);
308
                                        #ifdef WIN_ENV
331
                                        #ifdef WIN_ENV
309
                                        sfr.nFileExtension = (WORD)(strlen(outfilename) - strlen(".afs") + 1);
332
                                        sfr.nFileExtension = (WORD)(xstrlen(outfilename) - strlen(".afs") + 1);
310
                                        #endif
333
                                        #endif
311
                                        sfr.sfScript = 0; // FIXME: is that ok?
334
                                        sfr.sfScript = 0; // FIXME: is that ok?
312
 
335
 
313
                                        // We only want the parameters (ctl,map) in the temporary .afs file
336
                                        // We only want the parameters (ctl,map) in the temporary .afs file
314
                                        // It is important to remove the expressions, otherwise they would be
337
                                        // It is important to remove the expressions, otherwise they would be
Line 373... Line 396...
373
        int i,bUninitializedParams;
396
        int i,bUninitializedParams;
374
        Boolean showdialog;
397
        Boolean showdialog;
375
 
398
 
376
        if (!host_preserves_parameters()) {
399
        if (!host_preserves_parameters()) {
377
                // Workaround: Load settings in "FilterFoundryXX.afs" if host does not preserve pb->parameters
400
                // Workaround: Load settings in "FilterFoundryXX.afs" if host does not preserve pb->parameters
378
                char outfilename[255];
401
                TCHAR outfilename[MAX_PATH + 1];
379
                Boolean isStandalone;
402
                Boolean isStandalone;
380
                StandardFileReply sfr;
403
                StandardFileReply sfr;
381
                char* bakexpr[4];
404
                char* bakexpr[4];
382
 
405
 
383
                sfr.sfGood = true;
406
                sfr.sfGood = true;
Line 388... Line 411...
388
                // Reason: readPARMresource() reads parameters from the DLL while loadfile() reads parameters from the AFS file
411
                // Reason: readPARMresource() reads parameters from the DLL while loadfile() reads parameters from the AFS file
389
                // But loadfile() will reset gdata->standalone ...
412
                // But loadfile() will reset gdata->standalone ...
390
                isStandalone = readPARMresource((HMODULE)hDllInstance, &reason);
413
                isStandalone = readPARMresource((HMODULE)hDllInstance, &reason);
391
                if (isStandalone && (gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) {
414
                if (isStandalone && (gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) {
392
                        if (gdata->obfusc) {
415
                        if (gdata->obfusc) {
393
                                simplealert(_strdup("Incompatible obfuscation."));
416
                                simplealert((TCHAR*)TEXT("Incompatible obfuscation."));
394
                        }
417
                        }
395
                        else {
418
                        else {
396
                                simplealert(_strdup("Invalid parameter data."));
419
                                simplealert((TCHAR*)TEXT("Invalid parameter data."));
397
                        }
420
                        }
398
                        gdata->parmloaded = false;
421
                        gdata->parmloaded = false;
399
                        return false;
422
                        return false;
400
                }
423
                }
401
 
424
 
402
                get_temp_afs(&outfilename[0], isStandalone, &gdata->parm);
425
                get_temp_afs(&outfilename[0], isStandalone, &gdata->parm);
403
 
426
 
404
                myc2pstrcpy(sfr.sfFile.name, outfilename);
427
                xstrcpy(sfr.sfFile.szName, outfilename);
405
                #ifdef WIN_ENV
428
                #ifdef WIN_ENV
406
                sfr.nFileExtension = (WORD)(strlen(outfilename) - strlen(".afs") + 1);
429
                sfr.nFileExtension = (WORD)(xstrlen(outfilename) - strlen(".afs") + 1);
407
                #endif
430
                #endif
408
                sfr.sfScript = 0; // FIXME: is that ok?
431
                sfr.sfScript = 0; // FIXME: is that ok?
409
 
432
 
410
                // We only want the parameters (ctl,map) in the temporary .afs file
433
                // We only want the parameters (ctl,map) in the temporary .afs file
411
                if (isStandalone) {
434
                if (isStandalone) {
Line 434... Line 457...
434
 
457
 
435
                // see if saved parameters exist
458
                // see if saved parameters exist
436
                gdata->standalone = gdata->parmloaded = readPARMresource((HMODULE)hDllInstance,&reason);
459
                gdata->standalone = gdata->parmloaded = readPARMresource((HMODULE)hDllInstance,&reason);
437
                if (gdata->parmloaded && (gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) {
460
                if (gdata->parmloaded && (gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) {
438
                        if (gdata->obfusc) {
461
                        if (gdata->obfusc) {
439
                                simplealert(_strdup("Incompatible obfuscation."));
462
                                simplealert((TCHAR*)TEXT("Incompatible obfuscation."));
440
                        }
463
                        }
441
                        else {
464
                        else {
442
                                simplealert(_strdup("Invalid parameter data."));
465
                                simplealert((TCHAR*)TEXT("Invalid parameter data."));
443
                        }
466
                        }
444
                        gdata->parmloaded = false;
467
                        gdata->parmloaded = false;
445
                        return false;
468
                        return false;
446
                }
469
                }
447
 
470