Subversion Repositories filter_foundry

Rev

Rev 255 | Rev 271 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 259
1
/*
1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
5
 
5
 
6
    This program is free software; you can redistribute it and/or modify
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation; either version 2 of the License, or
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
9
    (at your option) any later version.
10
 
10
 
11
    This program is distributed in the hope that it will be useful,
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
14
    GNU General Public License for more details.
15
 
15
 
16
    You should have received a copy of the GNU General Public License
16
    You should have received a copy of the GNU General Public License
17
    along with this program; if not, write to the Free Software
17
    along with this program; if not, write to the Free Software
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
*/
19
*/
20
 
20
 
21
#include "world.h"
21
#include "world.h"
22
 
22
 
23
#include "PIFilter.h"
23
#include "PIFilter.h"
24
 
24
 
25
#include "entry.h"
25
#include "entry.h"
26
 
26
 
27
#include "choosefile.h"
27
#include "choosefile.h"
28
#include "ui.h"
28
#include "ui.h"
29
#include "file_compat.h"
29
#include "file_compat.h"
30
#include "symtab.h"
30
#include "symtab.h"
31
#include "PARM.h"
31
#include "PARM.h"
32
#include "preview.h"
32
#include "preview.h"
33
#include "misc.h"
33
#include "misc.h"
34
 
34
 
35
#ifndef INCLUDED_FF_H
35
#ifndef INCLUDED_FF_H
36
#define INCLUDED_FF_H
36
#define INCLUDED_FF_H
37
 
37
 
38
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
38
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
39
#define HOSTSIG_IRFANVIEW 'UP20'
39
#define HOSTSIG_IRFANVIEW 'UP20'
40
#define HOSTSIG_PHOTOSHOP '8BIM'
40
#define HOSTSIG_PHOTOSHOP '8BIM'
41
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // meh.
41
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // meh.
42
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // meh.
42
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // meh.
43
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
43
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
44
#define HOSTSIG_PAINT_NET 'NDP.'
44
#define HOSTSIG_PAINT_NET 'NDP.'
45
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
45
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
46
 
46
 
47
enum{
47
enum{
48
        TAB = 011,
48
        TAB = 011,
49
        LF  = 012,
49
        LF  = 012,
50
        CR  = 015,
50
        CR  = 015,
51
 
51
 
52
        CHUNK_ROWS = 64,
52
        CHUNK_ROWS = 64,
53
 
53
 
54
        PARM_TYPE = 'PARM',
54
        PARM_TYPE = 'PARM',
55
        PARM_ID = 16000,
55
        PARM_ID = 16000,
56
        OBFUSCDATA_ID = 16001,
56
        OBFUSCDATA_ID = 16001,
57
        TEXT_FILETYPE = 'TEXT',
57
        TEXT_FILETYPE = 'TEXT',
58
        SIG_SIMPLETEXT = 'ttxt',
58
        SIG_SIMPLETEXT = 'ttxt',
59
        PS_FILTER_FILETYPE = '8BFM',
59
        PS_FILTER_FILETYPE = '8BFM',
60
 
60
 
61
        READ_OBFUSC = 1
61
        READ_OBFUSC = 1
62
};
62
};
63
 
63
 
64
typedef struct{
64
typedef struct{
65
        Boolean standalone,parmloaded,obfusc;
65
        Boolean standalone,parmloaded,obfusc;
66
        PARM_T parm;
66
        PARM_T parm;
67
        #ifdef _WIN32
67
        #ifdef _WIN32
68
        HWND hWndMainDlg;
68
        HWND hWndMainDlg;
69
        #endif /* _WIN32 */
69
        #endif /* _WIN32 */
70
} globals_t;
70
} globals_t;
71
 
71
 
72
extern globals_t *gdata;
72
extern globals_t *gdata;
73
 
73
 
74
#define NUM_CELLS 0x100
74
#define NUM_CELLS 0x100
75
 
75
 
76
extern struct node *tree[4];
76
extern struct node *tree[4];
77
extern char *err[4];
77
extern char *err[4];
78
extern int errpos[4],errstart[4];//,nplanes;
78
extern int errpos[4],errstart[4];//,nplanes;
79
extern value_type slider[8],cell[NUM_CELLS],map[4][0x100];
79
extern value_type slider[8],cell[NUM_CELLS],map[4][0x100];
80
extern char *expr[4];
80
extern char *expr[4];
81
// extern long maxSpace;
81
// extern long maxSpace;
82
 
82
 
83
extern int tokpos,tokstart,varused[];
83
extern int tokpos,tokstart,varused[];
84
extern char *errstr;
84
extern char *errstr;
85
 
85
 
86
#define DBG(x) {}
86
#define DBG(x) {}
87
//#define DEBUG
87
//#define DEBUG
88
 
88
 
89
void DoPrepare (FilterRecordPtr epb);
89
void DoPrepare (FilterRecordPtr epb);
90
void DoStart (FilterRecordPtr epb);
90
void DoStart (FilterRecordPtr epb);
91
OSErr DoContinue (FilterRecordPtr epb);
91
OSErr DoContinue (FilterRecordPtr epb);
92
void DoFinish (FilterRecordPtr epb);
92
void DoFinish (FilterRecordPtr epb);
93
void RequestNext (FilterRecordPtr epb,long);
93
void RequestNext (FilterRecordPtr epb,long);
94
 
94
 
95
Boolean readparams(Handle h,Boolean alerts,char **reason);
95
Boolean readparams(Handle h,Boolean alerts,char **reason);
96
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
96
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
97
Boolean read8bfplugin(StandardFileReply *sfr,char **reason);
97
Boolean read8bfplugin(StandardFileReply *sfr,char **reason);
98
Handle readfileintohandle(FILEREF r);
98
Handle readfileintohandle(FILEREF r);
99
Boolean readfile(StandardFileReply *sfr,char **reason);
99
Boolean readfile(StandardFileReply *sfr,char **reason);
100
Boolean readPARM(Ptr h,PARM_T *parm,char **reasonstr,int fromwin);
100
Boolean readPARM(Ptr h,PARM_T *parm,char **reasonstr,int fromwin);
101
 
101
 
102
OSErr saveparams(Handle h);
102
OSErr saveparams(Handle h);
103
OSErr savehandleintofile(Handle h,FILEREF r);
103
OSErr savehandleintofile(Handle h,FILEREF r);
104
Boolean savefile(StandardFileReply *sfr);
104
Boolean savefile(StandardFileReply *sfr);
105
 
105
 
106
OSErr make_standalone(StandardFileReply *sfr);
106
OSErr make_standalone(StandardFileReply *sfr);
107
 
107
 
108
Boolean setup(FilterRecordPtr pb);
108
Boolean setup(FilterRecordPtr pb);
109
void evalpixel(unsigned char *outp,unsigned char *inp);
109
void evalpixel(unsigned char *outp,unsigned char *inp);
110
 
110
 
111
unsigned long printablehash(unsigned long hash);
111
unsigned long printablehash(unsigned long hash);
112
size_t fixpipl(PIPropertyList *pipl,size_t origsize,StringPtr title, long *event_id);
112
size_t fixpipl(PIPropertyList *pipl,size_t origsize,StringPtr title, long *event_id);
113
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
113
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
114
 
114
 
115
// Position 48..52 is "unknown2" of Photoshop FilterFactory PARM_T or "unknown1" of Premiere FilterFactory
115
// Position 48..52 is "unknown2" of Photoshop FilterFactory PARM_T or "unknown1" of Premiere FilterFactory
116
// We can assume that it is always 0x00000000, so we place the seed here
116
// We can assume that it is always 0x00000000, so we place the seed here
117
#define OBFUSC_SEED_POS 48
117
#define OBFUSC_SEED_POS 48
118
 
118
 
119
void obfusc(unsigned char* pparm, size_t size, size_t seed_position);
119
void obfusc(unsigned char* pparm, size_t size, size_t seed_position);
120
void deobfusc(unsigned char* pparm, size_t size, size_t seed_position);
120
void deobfusc(unsigned char* pparm, size_t size, size_t seed_position);
121
 
121
 
122
Boolean loadfile(StandardFileReply *sfr,char **reason);
122
Boolean loadfile(StandardFileReply *sfr,char **reason);
123
Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc);
123
Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc);
124
 
124
 
125
void dbglasterror(char*);
125
void dbglasterror(char*);
126
 
126
 
127
// from main.c
127
// from main.c
128
int64_t maxspace();
128
int64_t maxspace();
129
Boolean maxspace_available();
129
Boolean maxspace_available();
130
Boolean host_preserves_parameters();
130
Boolean host_preserves_parameters();
131
 
131
 
132
// from parser.y
132
// from parser.y
133
struct node *parseexpr(char *s);
133
struct node *parseexpr(char *s);
134
 
134
 
135
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
135
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
136
 
136
 
137
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
137
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
138
#define IMAGE_SIZE(x) ((x)->imageSize)
138
#define IMAGE_SIZE(x) ((x)->imageSize)
139
 
139
 
140
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
140
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
141
#define FILTER_RECT(x) ((x)->filterRect)
141
#define FILTER_RECT(x) ((x)->filterRect)
142
 
142
 
143
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
143
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
144
#define IN_RECT(x) ((x)->inRect)
144
#define IN_RECT(x) ((x)->inRect)
145
 
145
 
146
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
146
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
147
#define OUT_RECT(x) ((x)->outRect)
147
#define OUT_RECT(x) ((x)->outRect)
148
 
148
 
149
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
149
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
150
#define MASK_RECT(x) ((x)->maskRect)
150
#define MASK_RECT(x) ((x)->maskRect)
151
 
151
 
152
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
152
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
153
#define FLOAT_COORD(x) ((x)->floatCoord)
153
#define FLOAT_COORD(x) ((x)->floatCoord)
154
 
154
 
155
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
155
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
156
#define WHOLE_SIZE(x) ((x)->wholeSize)
156
#define WHOLE_SIZE(x) ((x)->wholeSize)
157
 
157
 
158
 
158
 
159
#ifdef _MSC_VER
159
#ifdef _MSC_VER
160
        // Microsoft dumbassery
160
        // Microsoft dumbassery
161
        #define strcasecmp _stricmp
161
        #define strcasecmp _stricmp
162
        #define snprintf _snprintf
162
        #define snprintf _snprintf
163
#endif /* _MSC_VER */
163
#endif /* _MSC_VER */
164
 
164
 
165
#endif /* INCLUDED_FF_H */
165
#endif /* INCLUDED_FF_H */
166
 
166