Subversion Repositories filter_foundry

Compare Revisions

No changes between revisions

Regard whitespace Rev 105 → Rev 106

/trunk/BUILDING.txt
85,6 → 85,41
is left in the "dist" directory.
 
 
Windows notes
-------------
 
To build with Visual Studio, you have to use nmake.
Currently, there is not Visual Studio project file.
 
To compile:
1. First download Flex and Bison from https://sourceforge.net/projects/winflexbison/
and unpack them on your disk.
2. Download the Adobe Photoshop SDK from https://www.adobe.com/devnet/photoshop/sdk.html
and unpack it on your disk.
3. Download the telegraphics common library from http://telegraphics.com.au/svn/common/trunk/
and unpack it on your disk.
4. Adjust paths in the nmake.mak file of Filter Foundry.
5. Run "Visual Studio Developer Command Prompt" from the start menu
6. Navigate to the Filter Foundry dir and run
nmake /f nmake.mak clean
nmake /f nmake.mak
 
Troubleshooting:
- If "rc" can't be found, install the Windows 10 SDK, and then copy
C:\Program Files (x86)\Windows Kits\10\bin\...\x64 to C:\Program Files (x86)\Windows Kits\10\bin\x86
see also https://stackoverflow.com/questions/43847542/rc-exe-no-longer-found-in-vs-2015-command-prompt
- If lex.yy.c can't be found, check the flex command (it generates lex.yy.c)
- If nmake gives the error message "makefile(28) : fatal error U1000: Syntax error: ")" missing in macro invocation"
then run nmake with the parameter "/f nmake.mak" (nmake calls Makefile by default, which is not optimized for nmake)
- If you run into any problems, try "nmake /f nmake.mak clean" followed by "nmake /f nmake.mak"
 
 
To build in Windows with the OpenWatcom IDE, see the wpj
subdirectory and notes kindly provided by Peter Heckert.
Please note that there might be problems with calling conventions;
the plugin might not work after the building process.
 
 
Development systems
-------------------
While a CodeWarrior 7 project is provided, MPW and mingw32 are recommended
95,6 → 130,3
 
MPW (http://developer.apple.com/tools/mpw-tools/) runs on PowerPC and
68K Macs under Mac OS 9 or earlier, or Classic under OS X.
 
To build in Windows with the OpenWatcom IDE, see the wpj subdirectory
and notes kindly provided by Peter Heckert.
/trunk/PARM.h
16,12 → 16,11
*/
 
#define PARM_SIZE 8296
#define PARM_SIG 7272 // don't know WHERE this value comes from...but it's in valid FF resources
 
#ifdef Rez
 
type 'PARM' {
longint = PARM_SIG; // cbSize; //size of this structure
longint = PARM_SIZE; // cbSize; //size of this structure
longint FilterFactory,standaloneFilter; // nVersion; //0=original FF, 1=standalone filter
array[8] { longint; }; // val[8]; //initial values of controls
longint noParameters,parametersDialog; // popDialog; //true if need to pop a parameter dialog
/trunk/PiPL.rc
173,7 → 173,7
VALUE "LegalCopyright", "Copyright (C) 2003-9 Toby Thain\0"
VALUE "License", "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\0"
/*VALUE "LegalTrademarks", "\0"*/
VALUE "OriginalFilename", "FilterFoundry.8bi\0"
VALUE "OriginalFilename", "FilterFoundry.8bf\0"
/*VALUE "PrivateBuild", "\0"*/
VALUE "ProductName", "Filter Foundry\0"
VALUE "ProductVersion", VERSION_STR "\0"
/trunk/cursor_hand_grab.cur
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/cursor_hand_open.cur
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/ff.h
31,6 → 31,9
#include "preview.h"
#include "misc.h"
 
#ifndef INCLUDED_FF_H
#define INCLUDED_FF_H
 
enum{
TAB = 011,
LF = 012,
49,6 → 52,9
typedef struct{
Boolean standalone,parmloaded,obfusc;
PARM_T parm;
#ifdef _WIN32
HWND hWndMainDlg;
#endif /* _WIN32 */
} globals_t;
 
extern globals_t *gdata;
58,7 → 64,7
extern int errpos[4],errstart[4];//,nplanes;
extern value_type slider[8],cell[0x100],map[4][0x100];
extern char *expr[4];
extern long maxSpace;
// extern long maxSpace;
 
extern int tokpos,tokstart,varused[];
extern char *errstr;
108,4 → 114,6
// Microsoft dumbassery
#define strcasecmp _stricmp
#define snprintf _snprintf
#endif
#endif /* _MSC_VER */
 
#endif /* INCLUDED_FF_H */
/trunk/funcs.c
274,6 → 274,13
#endif
}
 
/* rst(i) sets a random seed and returns 0. (undocumented Filter Factory function).
Added by DM, 18 Dec 2018 */
value_type ff_rst(value_type seed){
srand(seed);
return 0;
}
 
value_type zero_val = 0;
 
/* predefined symbols */
304,6 → 311,7
{0,TOK_FN1,"get", (pfunc_type)ff_get, 0},
{0,TOK_FN2,"put", (pfunc_type)ff_put, 0},
{0,TOK_FN10,"cnv",(pfunc_type)ff_cnv, 0},
{0,TOK_FN1,"rst", (pfunc_type)ff_rst, 0},
/* predefined variables (names >1 characters) */
{0,TOK_VAR,"dmin",0, &zero_val},
{0,TOK_VAR,"mmin",0, &zero_val},
/trunk/load_win.c
49,8 → 49,14
res = readPARM(pparm,&gdata->parm,reason,1 /*Windows format resource*/);
}else if( readobfusc && (resinfo = FindResource(hm,MAKEINTRESOURCE(OBFUSCDATA_ID),RT_RCDATA)) ){
if( (h = LoadResource(hm,resinfo)) && (pparm = LockResource(h)) ){
obfusc(pparm,SizeofResource(hm,resinfo));
res = readPARM(pparm,&gdata->parm,reason,1);
// Fix by DM, 18 Dec 2018:
// We need to copy the information, because the resource data is read-only
DWORD resSize = SizeofResource(hm,resinfo);
byte* copy = malloc(resSize);
memcpy(copy, pparm, resSize);
obfusc(copy, resSize);
res = readPARM(copy,&gdata->parm,reason,1);
free(copy);
}
}
return res;
/trunk/main.c
31,7 → 31,7
int errpos[4],errstart[4],nplanes,cnvused,chunksize,toprow;
value_type slider[8],cell[0x100],map[4][0x100];
char *expr[4];
long maxSpace;
// long maxSpace;
globals_t *gdata;
FilterRecordPtr gpb;
 
163,7 → 163,6
 
void DoPrepare(FilterRecordPtr pb){
int i;
long space = (pb->maxSpace*9)/10; // don't ask for more than 90% of available memory
 
for(i = 4; i--;){
if(expr[i]||tree[i]) DBG("expr[] or tree[] non-NULL in Prepare!");
170,10 → 169,21
expr[i] = NULL;
tree[i] = NULL;
}
 
// Commented out by DM, 18 Dec 2018:
// This code did not work on systems with 8 GB RAM:
/*
long space = (pb->maxSpace*9)/10; // don't ask for more than 90% of available memory
 
maxSpace = 512L<<10; // this is a wild guess, actually
if(maxSpace > space)
maxSpace = space;
pb->maxSpace = maxSpace;
*/
 
// New variant:
// TODO: Programmatically test if host supports pb->maxSpace64, and if it does so, use this value instead.
pb->maxSpace = ((double)pb->maxSpace/10)*9; // don't ask for more than 90% of available memory
}
 
void RequestNext(FilterRecordPtr pb,long toprow){
/trunk/make.c
167,6 → 167,21
int i;
unsigned char *p;
/* Do a small self-test to test if the stdlib implementation works as expected, i.e. that it only
* depends on the seed set by srand() and on nothing else.
*/
srand(0xdc43df3c);
int selftest1 = rand();
int selftest2 = rand();
int selftest3 = rand();
 
srand(0xdc43df3c);
if ((rand() != selftest1) || (rand() != selftest2) || (rand() != selftest3)) {
// This should never happen
simplealert("Stdcall rand() implementation does not work as expected. Obfuscation operation will be cancelled.");
return; // apply no obfuscation
}
 
/* Very simplistic. meant to hide from casual observation/loading only.
* Results are platform dependent, but this should not matter. */
srand(0xdc43df3c);
/trunk/nmake.mak
42,7 → 42,7
EXEC = FilterFoundry
 
# define location of Photoshop SDK headers
PSAPI = "c:\Adobe Photoshop CS4 SDK\photoshopapi"
PSAPI = "D:\FilterFoundry\adobe_photoshop_sdk_cc_2017_win\pluginsdk\photoshopapi"
 
# C compiler flags
CPPFLAGS = -DWIN32 -DWIN_ENV -DYY_SKIP_YYWRAP \
56,9 → 56,13
# resource compiler flags
RFLAGS = -i$(PSAPI)\Photoshop
 
# Path to flex and bison (you can download them at https://sourceforge.net/projects/winflexbison/ )
FLEX = D:\FilterFoundry\win_flex_bison\win_flex
BISON = D:\FilterFoundry\win_flex_bison\win_bison
 
OBJ = main.obj funcs.obj trigtab.obj process.obj node.obj symtab.obj \
ui.obj ui_build.obj preview.obj read.obj save.obj make.obj \
scripting.obj y.tab.obj lex.yy.obj ui_win.obj make_win.obj load_win.obj \
scripting.obj lex.yy.obj ui_win.obj make_win.obj load_win.obj \
..\common\tt\dbg_win.obj ..\common\tt\ui_compat_win.obj \
..\common\tt\choosefile_win.obj ui_build_win.obj \
..\common\tt\compat_string.obj ..\common\tt\compat_win.obj \
65,13 → 69,19
..\common\tt\file_compat_win.obj ..\common\tt\str.obj \
..\common\adobeplugin\dllmain.obj
 
all : $(EXEC).8bf
all : parser lexer $(EXEC).8bf
 
clean :
-del *.obj *.asm *.cod win_res.res $(EXEC).8bi $(EXEC).exp $(EXEC).lib $(EXEC).map
-del *.obj *.asm *.cod win_res.res $(EXEC).8bf $(EXEC).exp $(EXEC).lib $(EXEC).map
 
win_res.res : win_res.rc PiPL.rc PiPL_body.rc ui_win.rc caution.ico ui.h version.h
$(RC) $(RFLAGS) $(CPPFLAGS) win_res.rc
 
parser : parser.y
$(BISON) parser.y -d -y
lexer : lexer.l
$(FLEX) lexer.l y.tab.c
 
$(EXEC).8bf : $(OBJ) win_res.res
$(CC) /Fe$@ $(**F) $(LDFLAGS)
/trunk/process.c
124,25 → 124,6
long t,ticks = TICKCOUNT();
double x,y;
 
/* char s[0x100];sprintf(s,"process_scaled: pb->inData=%p outData=%p\n\
pb->inRect=(%d,%d,%d,%d) filterPiece=(%d,%d,%d,%d) outPiece=(%d,%d,%d,%d)\n\
pb->fRect=(%d,%d,%d,%d)\n\
top row offset (from inData) = %d\n\
left row offset = %d\n",
pb->inData,outData,
pb->inRect.left,pb->inRect.top,pb->inRect.right,pb->inRect.bottom,
filterPiece->left,filterPiece->top,filterPiece->right,filterPiece->bottom,
outPiece->left,outPiece->top,outPiece->right,outPiece->bottom,
pb->filterRect.left,pb->filterRect.top,pb->filterRect.right,pb->filterRect.bottom,
filterPiece->top - pb->filterRect.top + pb->filterRect.top - pb->inRect.top,
filterPiece->left - pb->filterRect.left + pb->filterRect.left - pb->inRect.left); dbg(s); */
 
if(needinput && !pb->inData){
simplealert("Error (process_scaled: pb->inData == NULL)."
" This problem is being investigated. Cannot apply the filter;"
" please re-launch Photoshop and try again.");
return userCanceledErr;
}else
// find base pointer to selection image data
image_ptr = (unsigned char*)pb->inData
+ (long)pb->inRowBytes*(pb->filterRect.top - pb->inRect.top)
/trunk/ui.c
289,7 → 289,7
// (e.g., on a 1GB WinXP system, PS CS2 reports 520MB maxSpace, so this will let us
// preview about 50MB of image data.)
zoomfactor = sqrt(maxSpace/(10.*preview_w*preview_h*nplanes));
zoomfactor = sqrt(gpb->maxSpace/(10.*preview_w*preview_h*nplanes));
if(zoomfactor > fitzoom)
zoomfactor = fitzoom;
if(zoomfactor < 1.)
332,7 → 332,11
return false; // end dialog
case OPENITEM:
if(!gdata->standalone && choosefiletypes("\pChoose filter settings",&sfr,&reply,types,2,
"All supported files (.afs, .8bf, .txt)\0*.afs;*.8bf;*.txt\0All files (*.*)\0*.*\0\0")){
"All supported files (.afs, .8bf, .txt)\0*.afs;*.8bf;*.txt\0All files (*.*)\0*.*\0\0"
#ifdef _WIN32
,gdata->hWndMainDlg
#endif /* _WIN32 */
)){
if(loadfile(&sfr,&reason)){
updatedialog(dp);
maindlgupdate(dp);
343,7 → 347,11
case SAVEITEM:
if(!gdata->standalone && putfile("\pSave filter settings",(StringPtr)"",
TEXT_FILETYPE,SIG_SIMPLETEXT,&reply,&sfr,
"afs","Settings file (.afs, .txt)\0*.afs;*.txt\0\0",1)){
"afs","Settings file (.afs, .txt)\0*.afs;*.txt\0\0",1
#ifdef _WIN32
,gdata->hWndMainDlg
#endif /* _WIN32 */
)){
if(savefile(&sfr))
completesave(&reply);
}
356,7 → 364,11
#endif
if( putfile("\pMake standalone filter",fname,
PS_FILTER_FILETYPE,kPhotoshopSignature,&reply,&sfr,
"8bf","Filter plugin file (.8bf)\0*.8bf\0\0",1) )
"8bf","Filter plugin file (.8bf)\0*.8bf\0\0",1
#ifdef _WIN32
,gdata->hWndMainDlg
#endif /* _WIN32 */
))
make_standalone(&sfr);
}
break;
/trunk/ui.h
65,6 → 65,9
#define ID_ZOOMOUTPICT 16002
#define ID_HANDCURSOR 16000
 
#define IDC_FF_HAND_OPEN 1001
#define IDC_FF_HAND_GRAB 1002
 
/* --- constants for terminology (scripting) resource */
#define AETE_ID 16000
#define vendorName "Telegraphics"
/trunk/ui_build.c
94,7 → 94,7
GetDlgItemText(dp,TITLEITEM,s,MAXFIELD); myc2pstrcpy(gdata->parm.title,s);
GetDlgItemText(dp,COPYRIGHTITEM,s,MAXFIELD); myc2pstrcpy(gdata->parm.copyright,s);
GetDlgItemText(dp,AUTHORITEM,s,MAXFIELD); myc2pstrcpy(gdata->parm.author,s);
gdata->parm.cbSize = PARM_SIG;
gdata->parm.cbSize = PARM_SIZE;
gdata->parm.nVersion = 1; //0=original FF, 1=standalone filter
for(i = needui = 0; i < 8; ++i){
gdata->parm.val[i] = slider[i];
/trunk/ui_build_win.c
60,5 → 60,5
Boolean builddialog(FilterRecordPtr pb){
PlatformData *p = pb->platformData;
return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(ID_BUILDDLG),
(HWND)p->hwnd,builddlgproc,0) == IDOK;
gdata->hWndMainDlg ? gdata->hWndMainDlg : (HWND)p->hwnd,builddlgproc,0) == IDOK;
}
/trunk/ui_win.c
31,6 → 31,8
#include "version.h"
 
HWND preview_hwnd;
HCURSOR hCurHandOpen;
HCURSOR hCurHandGrab;
 
extern HANDLE hDllInstance;
 
78,6 → 80,8
 
switch(wMsg){
case WM_INITDIALOG:
gdata->hWndMainDlg = hDlg;
 
if(gdata->standalone){
myp2cstrcpy(s,gdata->parm.title);
SetWindowText(hDlg,s); // window title bar
87,8 → 91,12
// see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3pbo.asp
hfnt = GetStockObject(ANSI_FIXED_FONT);
hCurHandOpen = LoadCursor(hDllInstance, MAKEINTRESOURCE(IDC_FF_HAND_OPEN));
hCurHandGrab = LoadCursor(hDllInstance, MAKEINTRESOURCE(IDC_FF_HAND_GRAB));
 
preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
GetClientRect(preview_hwnd, &preview_rect);
SetClassLongPtr(preview_hwnd, GCL_HCURSOR, (LONG_PTR)hCurHandOpen);
 
for(i = 0; i < 8; ++i){
SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETRANGE,TRUE,MAKELONG(0,255));
97,12 → 105,15
SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i, EM_SETLIMITTEXT,3,0);
}
for(i = 0; i < 4; ++i){
SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, EM_SETLIMITTEXT,MAXEXPR,0);
SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, EM_SETLIMITTEXT,MAXEXPR-1,0); // we need 1 byte as NUL terminator, so our formula can be max 1023
SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, WM_SETFONT,(WPARAM)hfnt,false);
}
 
maindlginit(hDlg);
break;
case WM_DESTROY:
gdata->hWndMainDlg = 0;
break;
case WM_DRAWITEM:
pdi = (DRAWITEMSTRUCT*)lParam;
if(pdi->itemAction == ODA_DRAWENTIRE){
124,6 → 135,7
if(item==PREVIEWITEM && GetCursorPos(&origpos)){
panning = true;
origscroll = preview_scroll;
SetCursor(hCurHandGrab);
SetCapture(hDlg);
break;
}
160,6 → 172,15
}
 
Boolean maindialog(FilterRecordPtr pb){
 
// For the preview image, we register a class, so that we can assign a mouse cursor to this class.
WNDCLASSEX clx;
clx.cbSize = sizeof(WNDCLASSEX);
GetClassInfoEx(hDllInstance, "Static", &clx);
clx.lpszClassName = "Preview";
RegisterClassEx(&clx);
 
// Now show the dialog
PlatformData *p = pb->platformData;
return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
(HWND)p->hwnd,maindlgproc,0) == IDOK;
/trunk/ui_win.rc
28,10 → 28,14
ZOOMIN_ICO ICON "zoomin.ico"
ZOOMOUT_ICO ICON "zoomout.ico"
 
/* Cursors for the preview window */
IDC_FF_HAND_OPEN CURSOR "cursor_hand_open.cur"
IDC_FF_HAND_GRAB CURSOR "cursor_hand_grab.cur"
 
/* left,top,w,h */
 
ID_MAINDLG DIALOG DISCARDABLE 150,50, 308,277
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Filter Foundry"
FONT 8, "MS Sans Serif"
BEGIN
41,7 → 45,8
PUSHBUTTON "Save...",SAVEITEM, 60,253, 42,14
PUSHBUTTON "Make...",MAKEITEM, 110,253, 42,14
 
CONTROL "",PREVIEWITEM, "Static",SS_OWNERDRAW|SS_NOTIFY, 15,10, 100,100
/* The class "Preview" is defined in ui_win.c */
CONTROL "",PREVIEWITEM, "Preview",SS_OWNERDRAW|SS_NOTIFY, 15,10, 100,100
CONTROL "ZOOMIN_ICO",ZOOMINITEM, "Static",SS_ICON|SS_REALSIZEIMAGE|SS_NOTIFY, 103,115, 12,12
CONTROL "ZOOMOUT_ICO",ZOOMOUTITEM, "Static",SS_ICON|SS_REALSIZEIMAGE|SS_NOTIFY, 15,115, 12,12
CONTROL "",ZOOMLEVELITEM, "Static",SS_CENTER|SS_NOTIFY, 37,115, 56,12
90,7 → 95,7
END
 
ID_PARAMDLG DIALOG DISCARDABLE 150,50, 308,161
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Filter Foundry"
FONT 8, "MS Sans Serif"
BEGIN
133,7 → 138,7
END
 
ID_BUILDDLG DIALOG DISCARDABLE 150,50, 208,243
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Make Standalone Filter"
FONT 8, "MS Sans Serif"
BEGIN
/trunk/version.h
96,15 → 96,27
02-Aug-2007: 1.5b4 - fix debug message spotted by Daniel Denk
26-Aug-2007: 1.5b6 - associativity of ?: operator (Harald Heim)
07-Jun-2009: 1.6b1 - clean up for 64-bit Windows build
19-Dec-2018: 1.6b2 - Fixed crash at filter startup when computer had too much RAM.
Fixed crash where built obfuscated filters could not be opened.
Added function rst(i) which is an undocumented function in Filter Factory for setting a random seed.
Size PARM_SIZE in PARM ressource corrected.
Extended NMake file to support flex and bison compilation.
Dialogs (build dialog, open and save dialogs) are now modal, i.e. the main window is locked when they are open. (*)
The preview dialog has now a hand cursor. (Open hand on hover. Grabbing hand on panning) (*)
Dialog boxes now have an [X] button to close the window.
(Changes by Daniel Marschall)
 
(*) This bug/solution was tested on Windows but needs to be verified and/or implemented on Mac.
 
*/
 
#define plugInName "FilterFoundry"
#define VERSION_STR "1.6b1"
#define VERSION_NUM 1,0x60,beta,1
#define VERSION_STR "1.6b2"
#define VERSION_NUM 1,0x60,beta,2
#define VERS_RSRC VERSION_NUM,verAustralia,VERSION_STR,"Filter Foundry " VERSION_STR
 
/* formatted for Win32 VERSIONINFO resource */
#define VI_VERS_NUM 1,6,0,1
#define VI_VERS_NUM 1,6,0,2
#define VI_FLAGS VS_FF_PRERELEASE /* 0 for final, or any of VS_FF_DEBUG,VS_FF_PATCHED,VS_FF_PRERELEASE,VS_FF_PRIVATEBUILD,VS_FF_SPECIALBUILD */
#define VI_COMMENTS "Beta.\r\n\r\nPlease contact support@telegraphics.com.au with any bug reports, suggestions or comments.\0" /* null terminated Comments field */
 
/trunk/wishlist/reference_examples/preview_pixelborder_bug.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property