Subversion Repositories filter_foundry

Rev

Rev 232 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 232 Rev 259
Line 1... Line 1...
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
/* This is PLATFORM INDEPENDENT user interface code - mainly dialog logic */
21
/* This is PLATFORM INDEPENDENT user interface code - mainly dialog logic */
22
 
22
 
23
#include "ff.h"
23
#include "ff.h"
24
#include "preview.h"
24
#include "preview.h"
25
 
25
 
26
#ifdef MAC_ENV
26
#ifdef MAC_ENV
27
        #include <fp.h>
27
        #include <fp.h>
28
#endif
28
#endif
29
#include <math.h>
29
#include <math.h>
30
 
30
 
31
#include "PIProperties.h"
31
#include "PIProperties.h"
32
 
32
 
33
extern FilterRecordPtr gpb;
33
extern FilterRecordPtr gpb;
34
 
34
 
35
PSPixelMap preview_pmap;
35
PSPixelMap preview_pmap;
36
PSPixelMask preview_pmask;
36
PSPixelMask preview_pmask;
37
Handle preview_handle;
37
Handle preview_handle;
38
UIRECT preview_rect;
38
UIRECT preview_rect;
39
int preview_w,preview_h,previewerr = false,needall = false,needinput = true;
39
int preview_w,preview_h,previewerr = false,needall = false,needinput = true;
40
Point preview_scroll;
40
Point preview_scroll;
41
Boolean preview_complete = false;
41
Boolean preview_complete = false;
42
double zoomfactor,fitzoom;
42
double zoomfactor,fitzoom;
43
 
43
 
44
Boolean setup_preview(FilterRecordPtr pb, int nplanes){
44
Boolean setup_preview(FilterRecordPtr pb, int nplanes){
45
        double zh,zv;
45
        double zh,zv;
46
 
46
 
47
        if(pb->displayPixels && pb->advanceState){
47
        if(pb->displayPixels && pb->advanceState){
48
                // Possibility 1: Only the part of the preview rect is filled with background color,
48
                // Possibility 1: Only the part of the preview rect is filled with background color,
49
                // which can be occupied by image data if zoom factor becomes 100%
49
                // which can be occupied by image data if zoom factor becomes 100%
50
                /*
50
                /*
51
                if (HAS_BIG_DOC(pb)) {
51
                if (HAS_BIG_DOC(pb)) {
52
                        preview_w = MIN(preview_rect.right - preview_rect.left,
52
                        preview_w = MIN(preview_rect.right - preview_rect.left,
53
                                                        BIGDOC_FILTER_RECT(pb).right - BIGDOC_FILTER_RECT(pb).left);
53
                                                        BIGDOC_FILTER_RECT(pb).right - BIGDOC_FILTER_RECT(pb).left);
54
                        preview_h = MIN(preview_rect.bottom - preview_rect.top,
54
                        preview_h = MIN(preview_rect.bottom - preview_rect.top,
55
                                                        BIGDOC_FILTER_RECT(pb).bottom - BIGDOC_FILTER_RECT(pb).top);
55
                                                        BIGDOC_FILTER_RECT(pb).bottom - BIGDOC_FILTER_RECT(pb).top);
56
                } else {
56
                } else {
57
                        preview_w = MIN(preview_rect.right - preview_rect.left,
57
                        preview_w = MIN(preview_rect.right - preview_rect.left,
58
                                                        FILTER_RECT(pb).right - FILTER_RECT(pb).left);
58
                                                        FILTER_RECT(pb).right - FILTER_RECT(pb).left);
59
                        preview_h = MIN(preview_rect.bottom - preview_rect.top,
59
                        preview_h = MIN(preview_rect.bottom - preview_rect.top,
60
                                                        FILTER_RECT(pb).bottom - FILTER_RECT(pb).top);
60
                                                        FILTER_RECT(pb).bottom - FILTER_RECT(pb).top);
61
                }
61
                }
62
                */
62
                */
63
                // Possibility 2: The whole preview rect is always filled with the background color,
63
                // Possibility 2: The whole preview rect is always filled with the background color,
64
                // so you can easily see what is the preview area and what is not
64
                // so you can easily see what is the preview area and what is not
65
                preview_w = preview_rect.right - preview_rect.left;
65
                preview_w = preview_rect.right - preview_rect.left;
66
                preview_h = preview_rect.bottom - preview_rect.top;
66
                preview_h = preview_rect.bottom - preview_rect.top;
67
 
67
 
68
                if (HAS_BIG_DOC(pb)) {
68
                if (HAS_BIG_DOC(pb)) {
69
                        zh = ((double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left) / (double)preview_w;
69
                        zh = ((double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left) / (double)preview_w;
70
                        zv = ((double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top) / (double)preview_h;
70
                        zv = ((double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top) / (double)preview_h;
71
                } else {
71
                } else {
72
                        zh = ((double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left) / (double)preview_w;
72
                        zh = ((double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left) / (double)preview_w;
73
                        zv = ((double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top) / (double)preview_h;
73
                        zv = ((double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top) / (double)preview_h;
74
                }
74
                }
75
                fitzoom = zh > zv ? zh : zv;
75
                fitzoom = zh > zv ? zh : zv;
76
 
76
 
77
                preview_pmap.version = 1;
77
                preview_pmap.version = 1;
78
                preview_pmap.bounds.left = preview_pmap.bounds.top = 0;
78
                preview_pmap.bounds.left = preview_pmap.bounds.top = 0;
79
                preview_pmap.bounds.right = preview_w;
79
                preview_pmap.bounds.right = preview_w;
80
                preview_pmap.bounds.bottom = preview_h;
80
                preview_pmap.bounds.bottom = preview_h;
81
                preview_pmap.imageMode = pb->imageMode;
81
                preview_pmap.imageMode = pb->imageMode;
82
                preview_pmap.rowBytes = nplanes*preview_w;
82
                preview_pmap.rowBytes = nplanes*preview_w;
83
                preview_pmap.colBytes = nplanes;
83
                preview_pmap.colBytes = nplanes;
84
                preview_pmap.planeBytes = 1; /*interleaved*/
84
                preview_pmap.planeBytes = 1; /*interleaved*/
85
        //      preview_pmap.baseAddr = preview_data;
85
        //      preview_pmap.baseAddr = preview_data;
86
        /* baseAddr must be set before using pixelmap */
86
        /* baseAddr must be set before using pixelmap */
87
 
87
 
88
                //---------------------------------------------------------------------------
88
                //---------------------------------------------------------------------------
89
                // Fields new in version 1:
89
                // Fields new in version 1:
90
                //---------------------------------------------------------------------------
90
                //---------------------------------------------------------------------------
91
                preview_pmap.mat = NULL;
91
                preview_pmap.mat = NULL;
92
 
92
 
93
                if( (pb->imageMode == plugInModeRGBColor && nplanes == 4)
93
                if( (pb->imageMode == plugInModeRGBColor && nplanes == 4)
94
                 || (pb->imageMode == plugInModeLabColor && nplanes == 4)
94
                 || (pb->imageMode == plugInModeLabColor && nplanes == 4)
95
                 || (pb->imageMode == plugInModeGrayScale && nplanes == 2)
95
                 || (pb->imageMode == plugInModeGrayScale && nplanes == 2)
96
                 || (pb->imageMode == plugInModeDuotone && nplanes == 2) )
96
                 || (pb->imageMode == plugInModeDuotone && nplanes == 2) )
97
                {
97
                {
98
                        preview_pmask.next = NULL;
98
                        preview_pmask.next = NULL;
99
        //              preview_pmask.maskData = preview_data+3;
99
        //              preview_pmask.maskData = preview_data+3;
100
                        preview_pmask.rowBytes = preview_pmap.rowBytes;
100
                        preview_pmask.rowBytes = preview_pmap.rowBytes;
101
                        preview_pmask.colBytes = nplanes;
101
                        preview_pmask.colBytes = nplanes;
102
                        preview_pmask.maskDescription = kSimplePSMask;
102
                        preview_pmask.maskDescription = kSimplePSMask;
103
                        preview_pmap.masks = &preview_pmask;
103
                        preview_pmap.masks = &preview_pmask;
104
                }else
104
                }else
105
                        preview_pmap.masks = NULL;
105
                        preview_pmap.masks = NULL;
106
 
106
 
107
                preview_handle = PINEWHANDLE((long)preview_h * preview_pmap.rowBytes);
107
                preview_handle = PINEWHANDLE((long)preview_h * preview_pmap.rowBytes);
108
        }else
108
        }else
109
                preview_handle = NULL;
109
                preview_handle = NULL;
110
        return preview_handle != NULL;
110
        return preview_handle != NULL;
111
 
111
 
112
        //---------------------------------------------------------------------------
112
        //---------------------------------------------------------------------------
113
        // Fields new in version 2:
113
        // Fields new in version 2:
114
        //---------------------------------------------------------------------------
114
        //---------------------------------------------------------------------------
115
//      preview_pmap.pixelOverlays;
115
//      preview_pmap.pixelOverlays;
116
//      preview_pmap.colorManagementOptions;
116
//      preview_pmap.colorManagementOptions;
117
}
117
}
118
 
118
 
119
void dispose_preview(){
119
void dispose_preview(){
120
        if(preview_handle){
120
        if(preview_handle){
121
                PIDISPOSEHANDLE(preview_handle);
121
                PIDISPOSEHANDLE(preview_handle);
122
                preview_handle = NULL;
122
                preview_handle = NULL;
123
        }
123
        }
124
}
124
}
125
 
125
 
126
void* memset_bgcolor(void* ptr, size_t num) {
126
void* memset_bgcolor(void* ptr, size_t num) {
127
        int i;
127
        int i;
128
        unsigned char* p;
128
        unsigned char* p;
129
 
129
 
130
        i = 0;
130
        i = 0;
131
        p = (unsigned char*)ptr;
131
        p = (unsigned char*)ptr;
132
        for (i=0; i<(int)num; ++i) {
132
        for (i=0; i<(int)num; ++i) {
133
#ifdef WIN_ENV
133
#ifdef WIN_ENV
134
                DWORD color;
134
                DWORD color;
135
 
135
 
136
                color = GetSysColor(COLOR_APPWORKSPACE);
136
                color = GetSysColor(COLOR_APPWORKSPACE);
137
 
137
 
138
                if (gpb->imageMode == plugInModeRGBColor) {
138
                if (gpb->imageMode == plugInModeRGBColor) {
139
                        if (i%nplanes == 0) p[i] = GetRValue(color);
139
                        if (i%nplanes == 0) p[i] = GetRValue(color);
140
                        if (i%nplanes == 1) p[i] = GetGValue(color);
140
                        if (i%nplanes == 1) p[i] = GetGValue(color);
141
                        if (i%nplanes == 2) p[i] = GetBValue(color);
141
                        if (i%nplanes == 2) p[i] = GetBValue(color);
142
                        if (i%nplanes == 3) p[i] = 255; // alpha channel
142
                        if (i%nplanes == 3) p[i] = 255; // alpha channel
143
                } else if (gpb->imageMode == plugInModeGrayScale) {
143
                } else if (gpb->imageMode == plugInModeGrayScale) {
144
                        uint8_t r, g, b;
144
                        uint8_t r, g, b;
145
 
145
 
146
                        r = GetRValue(color);
146
                        r = GetRValue(color);
147
                        g = GetGValue(color);
147
                        g = GetGValue(color);
148
                        b = GetBValue(color);
148
                        b = GetBValue(color);
149
 
149
 
150
                        if (i%nplanes == 0) p[i] = (uint8_t)(((299L*r)+(587L*g)+(114L*b))/1000);
150
                        if (i%nplanes == 0) p[i] = (uint8_t)(((299L*r)+(587L*g)+(114L*b))/1000);
151
                        if (i%nplanes == 1) p[i] = 255; // alpha channel
151
                        if (i%nplanes == 1) p[i] = 255; // alpha channel
152
                } else if (gpb->imageMode == plugInModeCMYKColor) {
152
                } else if (gpb->imageMode == plugInModeCMYKColor) {
153
                        uint8_t r, g, b;
153
                        uint8_t r, g, b;
154
                        double dmax, dr, dg, db, k, c, m, y;
154
                        double dmax, dr, dg, db, k, c, m, y;
155
 
155
 
156
                        r = GetRValue(color);
156
                        r = GetRValue(color);
157
                        g = GetGValue(color);
157
                        g = GetGValue(color);
158
                        b = GetBValue(color);
158
                        b = GetBValue(color);
159
 
159
 
160
                        dr = (double)r / 255;
160
                        dr = (double)r / 255;
161
                        dg = (double)g / 255;
161
                        dg = (double)g / 255;
162
                        db = (double)b / 255;
162
                        db = (double)b / 255;
163
 
163
 
164
                        dmax = dr;
164
                        dmax = dr;
165
                        if (dg>dmax) dmax = dg;
165
                        if (dg>dmax) dmax = dg;
166
                        if (db>dmax) dmax = db;
166
                        if (db>dmax) dmax = db;
167
 
167
 
168
                        k = 1 - dmax;
168
                        k = 1 - dmax;
169
                        c = (1 - dr - k) / (1 - k);
169
                        c = (1 - dr - k) / (1 - k);
170
                        m = (1 - dg - k) / (1 - k);
170
                        m = (1 - dg - k) / (1 - k);
171
                        y = (1 - db - k) / (1 - k);
171
                        y = (1 - db - k) / (1 - k);
172
 
172
 
173
                        if (i%nplanes == 0) p[i] = (uint8_t)(255 - c * 255);
173
                        if (i%nplanes == 0) p[i] = (uint8_t)(255 - c * 255);
174
                        if (i%nplanes == 1) p[i] = (uint8_t)(255 - m * 255);
174
                        if (i%nplanes == 1) p[i] = (uint8_t)(255 - m * 255);
175
                        if (i%nplanes == 2) p[i] = (uint8_t)(255 - y * 255);
175
                        if (i%nplanes == 2) p[i] = (uint8_t)(255 - y * 255);
176
                        if (i%nplanes == 3) p[i] = (uint8_t)(255 - k * 255);
176
                        if (i%nplanes == 3) p[i] = (uint8_t)(255 - k * 255);
177
                } else {
177
                } else {
178
                        // FIXME: If we are in such a non supported color mode, then
178
                        // FIXME: If we are in such a non supported color mode, then
179
                        //        these color codes would be all wrong!
179
                        //        these color codes would be all wrong!
180
                        //        Just to be safe use (what is probably) white
180
                        //        Just to be safe use (what is probably) white
181
                        p[i] = 0xFF;
181
                        p[i] = 0xFF;
182
 
182
 
183
                        /*
183
                        /*
184
                        #define plugInModeBitmap                        0
184
                        #define plugInModeBitmap                        0
185
                        #define plugInModeGrayScale                     1 supported
185
                        #define plugInModeGrayScale                     1 supported
186
                        #define plugInModeIndexedColor          2
186
                        #define plugInModeIndexedColor          2
187
                        #define plugInModeRGBColor                      3 supported
187
                        #define plugInModeRGBColor                      3 supported
188
                        #define plugInModeCMYKColor                     4 supported
188
                        #define plugInModeCMYKColor                     4 supported
189
                        #define plugInModeHSLColor                      5
189
                        #define plugInModeHSLColor                      5
190
                        #define plugInModeHSBColor                      6
190
                        #define plugInModeHSBColor                      6
191
                        #define plugInModeMultichannel          7
191
                        #define plugInModeMultichannel          7
192
                        #define plugInModeDuotone                       8
192
                        #define plugInModeDuotone                       8
193
                        #define plugInModeLabColor                      9
193
                        #define plugInModeLabColor                      9
194
                        #define plugInModeGray16                        10
194
                        #define plugInModeGray16                        10
195
                        #define plugInModeRGB48                         11
195
                        #define plugInModeRGB48                         11
196
                        #define plugInModeLab48                         12
196
                        #define plugInModeLab48                         12
197
                        #define plugInModeCMYK64                        13
197
                        #define plugInModeCMYK64                        13
198
                        #define plugInModeDeepMultichannel      14
198
                        #define plugInModeDeepMultichannel      14
199
                        #define plugInModeDuotone16                     15
199
                        #define plugInModeDuotone16                     15
200
                        #define plugInModeRGB96                         16
200
                        #define plugInModeRGB96                         16
201
                        #define plugInModeGray32                        17
201
                        #define plugInModeGray32                        17
202
                        */
202
                        */
203
 
203
 
204
                }
204
                }
205
#else
205
#else
206
                // This is the behavior of FilterFoundry <1.7 was this (filled with 0xFF)
206
                // This is the behavior of FilterFoundry <1.7 was this (filled with 0xFF)
207
                // FIXME: Should we do something fancy here, too?
207
                // FIXME: Should we do something fancy here, too?
208
                p[i] = 0xFF;
208
                p[i] = 0xFF;
209
#endif
209
#endif
210
        }
210
        }
211
        return ptr;
211
        return ptr;
212
}
212
}
213
 
213
 
214
void recalc_preview_olddoc(FilterRecordPtr pb, DIALOGREF dp) {
214
void recalc_preview_olddoc(FilterRecordPtr pb, DIALOGREF dp) {
215
        OSErr e;
215
        OSErr e;
216
        double scaledw, scaledh;
216
        double scaledw, scaledh;
217
        int j, n, imgw, imgh;
217
        int j, n, imgw, imgh;
218
        Rect r, outRect;
218
        Rect r, outRect;
219
        Ptr outrow;
219
        Ptr outrow;
220
 
220
 
221
        preview_complete = false;
221
        preview_complete = false;
222
 
222
 
223
        if (preview_handle) {
223
        if (preview_handle) {
224
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
224
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
225
                scaledw = zoomfactor * preview_w;
225
                scaledw = zoomfactor * preview_w;
226
                if (scaledw > ((double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left))
226
                if (scaledw > ((double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left))
227
                        scaledw = (double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left;
227
                        scaledw = (double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left;
228
                scaledh = zoomfactor * preview_h;
228
                scaledh = zoomfactor * preview_h;
229
                if (scaledh > ((double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top))
229
                if (scaledh > ((double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top))
230
                        scaledh = (double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top;
230
                        scaledh = (double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top;
231
 
231
 
232
                /* scale clipped preview area down again - this becomes the pixel size of preview */
232
                /* scale clipped preview area down again - this becomes the pixel size of preview */
233
                imgw = (int)ceil(scaledw / zoomfactor);
233
                imgw = (int)ceil(scaledw / zoomfactor);
234
                if (imgw > preview_w)
234
                if (imgw > preview_w)
235
                        imgw = preview_w;
235
                        imgw = preview_w;
236
                imgh = (int)ceil(scaledh / zoomfactor);
236
                imgh = (int)ceil(scaledh / zoomfactor);
237
                if (imgh > preview_h)
237
                if (imgh > preview_h)
238
                        imgh = preview_h;
238
                        imgh = preview_h;
239
 
239
 
240
                /* compute source data rectangle (inRect) */
240
                /* compute source data rectangle (inRect) */
241
 
241
 
242
                /* centre preview on filtered part of input image, adding scroll offset */
242
                /* centre preview on filtered part of input image, adding scroll offset */
243
                r.left = (int16)(((double)FILTER_RECT(pb).left + (double)FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
243
                r.left = (int16)(((double)FILTER_RECT(pb).left + (double)FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
244
                /* make sure it does not go outside the input area */
244
                /* make sure it does not go outside the input area */
245
                if (r.left < FILTER_RECT(pb).left) {
245
                if (r.left < FILTER_RECT(pb).left) {
246
                        preview_scroll.h += FILTER_RECT(pb).left - r.left;
246
                        preview_scroll.h += FILTER_RECT(pb).left - r.left;
247
                        r.left = FILTER_RECT(pb).left;
247
                        r.left = FILTER_RECT(pb).left;
248
                }
248
                }
249
                else if ((double)r.left + scaledw > FILTER_RECT(pb).right) {
249
                else if ((double)r.left + scaledw > FILTER_RECT(pb).right) {
250
                        preview_scroll.h += (int16)((double)FILTER_RECT(pb).right - ((double)r.left + scaledw));
250
                        preview_scroll.h += (int16)((double)FILTER_RECT(pb).right - ((double)r.left + scaledw));
251
                        r.left = (int16)((double)FILTER_RECT(pb).right - scaledw);
251
                        r.left = (int16)((double)FILTER_RECT(pb).right - scaledw);
252
                }
252
                }
253
                r.right = (int16)((double)r.left + scaledw);
253
                r.right = (int16)((double)r.left + scaledw);
254
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
254
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
255
 
255
 
256
                /* now compute for vertical */
256
                /* now compute for vertical */
257
                r.top = (int16)(((double)FILTER_RECT(pb).top + (double)FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
257
                r.top = (int16)(((double)FILTER_RECT(pb).top + (double)FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
258
                if (r.top < FILTER_RECT(pb).top) {
258
                if (r.top < FILTER_RECT(pb).top) {
259
                        preview_scroll.v += FILTER_RECT(pb).top - r.top;
259
                        preview_scroll.v += FILTER_RECT(pb).top - r.top;
260
                        r.top = FILTER_RECT(pb).top;
260
                        r.top = FILTER_RECT(pb).top;
261
                }
261
                }
262
                else if ((double)r.top + scaledh > FILTER_RECT(pb).bottom) {
262
                else if ((double)r.top + scaledh > FILTER_RECT(pb).bottom) {
263
                        preview_scroll.v += (int16)(FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
263
                        preview_scroll.v += (int16)(FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
264
                        r.top = (int16)((double)FILTER_RECT(pb).bottom - scaledh);
264
                        r.top = (int16)((double)FILTER_RECT(pb).bottom - scaledh);
265
                }
265
                }
266
                r.bottom = (int16)((double)r.top + scaledh);
266
                r.bottom = (int16)((double)r.top + scaledh);
267
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
267
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
268
 
268
 
269
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
269
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
270
                if (needall)
270
                if (needall)
271
                        SETRECT(IN_RECT(pb), 0, 0, IMAGE_SIZE(pb).h, IMAGE_SIZE(pb).v);
271
                        SETRECT(IN_RECT(pb), 0, 0, IMAGE_SIZE(pb).h, IMAGE_SIZE(pb).v);
272
                else
272
                else
273
                        IN_RECT(pb) = r;
273
                        IN_RECT(pb) = r;
274
 
274
 
275
                OUT_RECT(pb) = IN_RECT(pb);
275
                OUT_RECT(pb) = IN_RECT(pb);
276
                SETRECT(MASK_RECT(pb), 0, 0, 0, 0);
276
                SETRECT(MASK_RECT(pb), 0, 0, 0, 0);
277
                pb->inLoPlane = pb->outLoPlane = 0;
277
                pb->inLoPlane = pb->outLoPlane = 0;
278
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
278
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
279
 
279
 
280
                if (!needinput || !(e = pb->advanceState())) {
280
                if (!needinput || !(e = pb->advanceState())) {
281
                        Ptr outptr = PILOCKHANDLE(preview_handle, false);
281
                        Ptr outptr = PILOCKHANDLE(preview_handle, false);
282
                        int blankrows = (preview_h - imgh) / 2,
282
                        int blankrows = (preview_h - imgh) / 2,
283
                                blankcols = (preview_w - imgw) / 2,
283
                                blankcols = (preview_w - imgw) / 2,
284
                                pmrb = preview_pmap.rowBytes;
284
                                pmrb = preview_pmap.rowBytes;
285
 
285
 
286
                        evalinit();
286
                        evalinit();
287
 
287
 
288
                        SETRECT(outRect, 0, 0, imgw, imgh);
288
                        SETRECT(outRect, 0, 0, imgw, imgh);
289
 
289
 
290
                        e = process_scaled_olddoc(pb, false, r, outRect,
290
                        e = process_scaled_olddoc(pb, false, r, outRect,
291
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
291
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
292
                        if (blankrows) {
292
                        if (blankrows) {
293
                                // blank rows on top of preview:
293
                                // blank rows on top of preview:
294
                                memset_bgcolor(outptr, pmrb * blankrows);
294
                                memset_bgcolor(outptr, pmrb * blankrows);
295
                                // blank rows below preview:
295
                                // blank rows below preview:
296
                                n = preview_h - blankrows - imgh;
296
                                n = preview_h - blankrows - imgh;
297
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
297
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
298
                        }
298
                        }
299
                        if (blankcols) {
299
                        if (blankcols) {
300
                                n = preview_w - blankcols - imgw;
300
                                n = preview_w - blankcols - imgw;
301
                                outrow = outptr + pmrb * blankrows;
301
                                outrow = outptr + pmrb * blankrows;
302
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
302
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
303
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
303
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
304
                                        memset_bgcolor(outrow, nplanes * blankcols);
304
                                        memset_bgcolor(outrow, nplanes * blankcols);
305
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
305
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
306
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
306
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
307
                                        outrow += pmrb;
307
                                        outrow += pmrb;
308
                                }
308
                                }
309
                        }
309
                        }
310
 
310
 
311
                        if (!e) {
311
                        if (!e) {
312
                                preview_complete = true;
312
                                preview_complete = true;
313
 
313
 
314
#ifdef WIN_ENV
314
#ifdef WIN_ENV
315
                                {
315
                                {
316
                                        extern HWND preview_hwnd;
316
                                        extern HWND preview_hwnd;
317
                                        HDC hdc = GetDC(preview_hwnd);
317
                                        HDC hdc = GetDC(preview_hwnd);
318
 
318
 
319
                                        drawpreview(dp, hdc, outptr);
319
                                        drawpreview(dp, hdc, outptr);
320
 
320
 
321
                                        ReleaseDC(preview_hwnd, hdc);
321
                                        ReleaseDC(preview_hwnd, hdc);
322
                                }
322
                                }
323
#else
323
#else
324
                                {
324
                                {
325
                                        GrafPtr saveport;
325
                                        GrafPtr saveport;
326
 
326
 
327
                                        GetPort(&saveport);
327
                                        GetPort(&saveport);
328
                                        SetPortDialogPort(dp);
328
                                        SetPortDialogPort(dp);
329
 
329
 
330
                                        drawpreview(dp, NULL, outptr);
330
                                        drawpreview(dp, NULL, outptr);
331
 
331
 
332
                                        SetPort(saveport);
332
                                        SetPort(saveport);
333
                                }
333
                                }
334
#endif
334
#endif
335
                        }
335
                        }
336
 
336
 
337
                        PIUNLOCKHANDLE(preview_handle);
337
                        PIUNLOCKHANDLE(preview_handle);
338
                }
338
                }
339
 
339
 
340
                if (e && !previewerr) {
340
                if (e && !previewerr) {
341
                        alertuser(_strdup("Could not build preview at chosen zoom level."),
341
                        alertuser(_strdup("Could not build preview at chosen zoom level."),
342
                                e == memFullErr && !needall ? _strdup("The image is too large for available memory. Try zooming in.\nIf that does not help, cancel and retry the filter.") : _strdup(""));
342
                                e == memFullErr && !needall ? _strdup("The image is too large for available memory. Try zooming in.\nIf that does not help, cancel and retry the filter.") : _strdup(""));
343
                        previewerr = true;
343
                        previewerr = true;
344
                }
344
                }
345
 
345
 
346
        }
346
        }
347
}
347
}
348
 
348
 
349
void recalc_preview_bigdoc(FilterRecordPtr pb, DIALOGREF dp) {
349
void recalc_preview_bigdoc(FilterRecordPtr pb, DIALOGREF dp) {
350
        OSErr e;
350
        OSErr e;
351
        double scaledw, scaledh;
351
        double scaledw, scaledh;
352
        int j, n, imgw, imgh;
352
        int j, n, imgw, imgh;
353
        VRect r, outRect;
353
        VRect r, outRect;
354
        Ptr outrow;
354
        Ptr outrow;
355
 
355
 
356
        preview_complete = false;
356
        preview_complete = false;
357
 
357
 
358
        if (preview_handle) {
358
        if (preview_handle) {
359
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
359
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
360
                scaledw = zoomfactor * preview_w;
360
                scaledw = zoomfactor * preview_w;
361
                if (scaledw > ((double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left))
361
                if (scaledw > ((double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left))
362
                        scaledw = (double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left;
362
                        scaledw = (double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left;
363
                scaledh = zoomfactor * preview_h;
363
                scaledh = zoomfactor * preview_h;
364
                if (scaledh > ((double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top))
364
                if (scaledh > ((double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top))
365
                        scaledh = (double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top;
365
                        scaledh = (double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top;
366
 
366
 
367
                /* scale clipped preview area down again - this becomes the pixel size of preview */
367
                /* scale clipped preview area down again - this becomes the pixel size of preview */
368
                imgw = (int)ceil(scaledw / zoomfactor);
368
                imgw = (int)ceil(scaledw / zoomfactor);
369
                if (imgw > preview_w)
369
                if (imgw > preview_w)
370
                        imgw = preview_w;
370
                        imgw = preview_w;
371
                imgh = (int)ceil(scaledh / zoomfactor);
371
                imgh = (int)ceil(scaledh / zoomfactor);
372
                if (imgh > preview_h)
372
                if (imgh > preview_h)
373
                        imgh = preview_h;
373
                        imgh = preview_h;
374
 
374
 
375
                /* compute source data rectangle (inRect) */
375
                /* compute source data rectangle (inRect) */
376
 
376
 
377
                /* centre preview on filtered part of input image, adding scroll offset */
377
                /* centre preview on filtered part of input image, adding scroll offset */
378
                r.left = (int32)(((double)BIGDOC_FILTER_RECT(pb).left + (double)BIGDOC_FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
378
                r.left = (int32)(((double)BIGDOC_FILTER_RECT(pb).left + (double)BIGDOC_FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
379
                /* make sure it does not go outside the input area */
379
                /* make sure it does not go outside the input area */
380
                if (r.left < BIGDOC_FILTER_RECT(pb).left) {
380
                if (r.left < BIGDOC_FILTER_RECT(pb).left) {
381
                        preview_scroll.h += BIGDOC_FILTER_RECT(pb).left - r.left;
381
                        preview_scroll.h += BIGDOC_FILTER_RECT(pb).left - r.left;
382
                        r.left = BIGDOC_FILTER_RECT(pb).left;
382
                        r.left = BIGDOC_FILTER_RECT(pb).left;
383
                }
383
                }
384
                else if ((double)r.left + scaledw > BIGDOC_FILTER_RECT(pb).right) {
384
                else if ((double)r.left + scaledw > BIGDOC_FILTER_RECT(pb).right) {
385
                        preview_scroll.h += (int32)((double)BIGDOC_FILTER_RECT(pb).right - ((double)r.left + scaledw));
385
                        preview_scroll.h += (int32)((double)BIGDOC_FILTER_RECT(pb).right - ((double)r.left + scaledw));
386
                        r.left = (int32)((double)BIGDOC_FILTER_RECT(pb).right - scaledw);
386
                        r.left = (int32)((double)BIGDOC_FILTER_RECT(pb).right - scaledw);
387
                }
387
                }
388
                r.right = (int32)((double)r.left + scaledw);
388
                r.right = (int32)((double)r.left + scaledw);
389
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
389
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
390
 
390
 
391
                /* now compute for vertical */
391
                /* now compute for vertical */
392
                r.top = (int32)(((double)BIGDOC_FILTER_RECT(pb).top + (double)BIGDOC_FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
392
                r.top = (int32)(((double)BIGDOC_FILTER_RECT(pb).top + (double)BIGDOC_FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
393
                if (r.top < BIGDOC_FILTER_RECT(pb).top) {
393
                if (r.top < BIGDOC_FILTER_RECT(pb).top) {
394
                        preview_scroll.v += BIGDOC_FILTER_RECT(pb).top - r.top;
394
                        preview_scroll.v += BIGDOC_FILTER_RECT(pb).top - r.top;
395
                        r.top = BIGDOC_FILTER_RECT(pb).top;
395
                        r.top = BIGDOC_FILTER_RECT(pb).top;
396
                }
396
                }
397
                else if ((double)r.top + scaledh > BIGDOC_FILTER_RECT(pb).bottom) {
397
                else if ((double)r.top + scaledh > BIGDOC_FILTER_RECT(pb).bottom) {
398
                        preview_scroll.v += (int32)(BIGDOC_FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
398
                        preview_scroll.v += (int32)(BIGDOC_FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
399
                        r.top = (int32)((double)BIGDOC_FILTER_RECT(pb).bottom - scaledh);
399
                        r.top = (int32)((double)BIGDOC_FILTER_RECT(pb).bottom - scaledh);
400
                }
400
                }
401
                r.bottom = (int32)((double)r.top + scaledh);
401
                r.bottom = (int32)((double)r.top + scaledh);
402
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
402
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
403
 
403
 
404
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
404
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
405
                if (needall)
405
                if (needall)
406
                        SETRECT(BIGDOC_IN_RECT(pb), 0, 0, BIGDOC_IMAGE_SIZE(pb).h, BIGDOC_IMAGE_SIZE(pb).v);
406
                        SETRECT(BIGDOC_IN_RECT(pb), 0, 0, BIGDOC_IMAGE_SIZE(pb).h, BIGDOC_IMAGE_SIZE(pb).v);
407
                else
407
                else
408
                        BIGDOC_IN_RECT(pb) = r;
408
                        BIGDOC_IN_RECT(pb) = r;
409
 
409
 
410
                BIGDOC_OUT_RECT(pb) = BIGDOC_IN_RECT(pb);
410
                BIGDOC_OUT_RECT(pb) = BIGDOC_IN_RECT(pb);
411
                SETRECT(BIGDOC_MASK_RECT(pb), 0, 0, 0, 0);
411
                SETRECT(BIGDOC_MASK_RECT(pb), 0, 0, 0, 0);
412
                pb->inLoPlane = pb->outLoPlane = 0;
412
                pb->inLoPlane = pb->outLoPlane = 0;
413
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
413
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
414
 
414
 
415
                if (!needinput || !(e = pb->advanceState())) {
415
                if (!needinput || !(e = pb->advanceState())) {
416
                        Ptr outptr = PILOCKHANDLE(preview_handle, false);
416
                        Ptr outptr = PILOCKHANDLE(preview_handle, false);
417
                        int blankrows = (preview_h - imgh) / 2,
417
                        int blankrows = (preview_h - imgh) / 2,
418
                                blankcols = (preview_w - imgw) / 2,
418
                                blankcols = (preview_w - imgw) / 2,
419
                                pmrb = preview_pmap.rowBytes;
419
                                pmrb = preview_pmap.rowBytes;
420
 
420
 
421
                        evalinit();
421
                        evalinit();
422
 
422
 
423
                        SETRECT(outRect, 0, 0, imgw, imgh);
423
                        SETRECT(outRect, 0, 0, imgw, imgh);
424
 
424
 
425
                        e = process_scaled_bigdoc(pb, false, r, outRect,
425
                        e = process_scaled_bigdoc(pb, false, r, outRect,
426
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
426
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
427
                        if (blankrows) {
427
                        if (blankrows) {
428
                                // blank rows on top of preview:
428
                                // blank rows on top of preview:
429
                                memset_bgcolor(outptr, pmrb * blankrows);
429
                                memset_bgcolor(outptr, pmrb * blankrows);
430
                                // blank rows below preview:
430
                                // blank rows below preview:
431
                                n = preview_h - blankrows - imgh;
431
                                n = preview_h - blankrows - imgh;
432
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
432
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
433
                        }
433
                        }
434
                        if (blankcols) {
434
                        if (blankcols) {
435
                                n = preview_w - blankcols - imgw;
435
                                n = preview_w - blankcols - imgw;
436
                                outrow = outptr + pmrb * blankrows;
436
                                outrow = outptr + pmrb * blankrows;
437
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
437
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
438
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
438
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
439
                                        memset_bgcolor(outrow, nplanes * blankcols);
439
                                        memset_bgcolor(outrow, nplanes * blankcols);
440
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
440
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
441
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
441
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
442
                                        outrow += pmrb;
442
                                        outrow += pmrb;
443
                                }
443
                                }
444
                        }
444
                        }
445
 
445
 
446
                        if (!e) {
446
                        if (!e) {
447
                                preview_complete = true;
447
                                preview_complete = true;
448
 
448
 
449
#ifdef WIN_ENV
449
#ifdef WIN_ENV
450
                                {
450
                                {
451
                                        extern HWND preview_hwnd;
451
                                        extern HWND preview_hwnd;
452
                                        HDC hdc = GetDC(preview_hwnd);
452
                                        HDC hdc = GetDC(preview_hwnd);
453
 
453
 
454
                                        drawpreview(dp, hdc, outptr);
454
                                        drawpreview(dp, hdc, outptr);
455
 
455
 
456
                                        ReleaseDC(preview_hwnd, hdc);
456
                                        ReleaseDC(preview_hwnd, hdc);
457
                                }
457
                                }
458
#else
458
#else
459
                                {
459
                                {
460
                                        GrafPtr saveport;
460
                                        GrafPtr saveport;
461
 
461
 
462
                                        GetPort(&saveport);
462
                                        GetPort(&saveport);
463
                                        SetPortDialogPort(dp);
463
                                        SetPortDialogPort(dp);
464
 
464
 
465
                                        drawpreview(dp, NULL, outptr);
465
                                        drawpreview(dp, NULL, outptr);
466
 
466
 
467
                                        SetPort(saveport);
467
                                        SetPort(saveport);
468
                                }
468
                                }
469
#endif
469
#endif
470
                        }
470
                        }
471
 
471
 
472
                        PIUNLOCKHANDLE(preview_handle);
472
                        PIUNLOCKHANDLE(preview_handle);
473
                }
473
                }
474
 
474
 
475
                if (e && !previewerr) {
475
                if (e && !previewerr) {
476
                        alertuser(_strdup("Could not build preview at chosen zoom level."),
476
                        alertuser(_strdup("Could not build preview at chosen zoom level."),
477
                                e == memFullErr && !needall ? _strdup("The image is too large for available memory. Try zooming in.\nIf that does not help, cancel and retry the filter.") : _strdup(""));
477
                                e == memFullErr && !needall ? _strdup("The image is too large for available memory. Try zooming in.\nIf that does not help, cancel and retry the filter.") : _strdup(""));
478
                        previewerr = true;
478
                        previewerr = true;
479
                }
479
                }
480
 
480
 
481
        }
481
        }
482
}
482
}
483
 
483
 
484
void recalc_preview(FilterRecordPtr pb, DIALOGREF dp) {
484
void recalc_preview(FilterRecordPtr pb, DIALOGREF dp) {
485
        if (HAS_BIG_DOC(pb)) {
485
        if (HAS_BIG_DOC(pb)) {
486
                recalc_preview_bigdoc(pb, dp);
486
                recalc_preview_bigdoc(pb, dp);
487
        }
487
        }
488
        else {
488
        else {
489
                recalc_preview_olddoc(pb, dp);
489
                recalc_preview_olddoc(pb, dp);
490
        }
490
        }
491
}
491
}
492
 
492
 
493
OSErr drawpreview(DIALOGREF dp,void *hdc,Ptr imageptr){
493
OSErr drawpreview(DIALOGREF dp,void *hdc,Ptr imageptr){
494
        intptr_t watchsusp;
494
        intptr_t watchsusp;
495
        OSErr e = noErr;
495
        OSErr e = noErr;
496
        VRect srcRect;
496
        VRect srcRect;
497
        UIRECT imagebounds;
497
        UIRECT imagebounds;
498
 
498
 
499
        if(preview_handle && preview_complete){
499
        if(preview_handle && preview_complete){
500
 
500
 
501
                srcRect = preview_pmap.bounds;
501
                srcRect = preview_pmap.bounds;
502
 
502
 
503
                imagebounds.left = (preview_rect.left + preview_rect.right - preview_w)/2;
503
                imagebounds.left = (preview_rect.left + preview_rect.right - preview_w)/2;
504
                imagebounds.top = (preview_rect.top + preview_rect.bottom - preview_h)/2;
504
                imagebounds.top = (preview_rect.top + preview_rect.bottom - preview_h)/2;
505
                imagebounds.right = imagebounds.left + preview_w;
505
                imagebounds.right = imagebounds.left + preview_w;
506
                imagebounds.bottom = imagebounds.top + preview_h;
506
                imagebounds.bottom = imagebounds.top + preview_h;
507
 
507
 
508
                preview_pmap.baseAddr = imageptr;
508
                preview_pmap.baseAddr = imageptr;
509
                preview_pmask.maskData = imageptr+3; // FIXME: is this offset correct for all modes?!
509
                preview_pmask.maskData = imageptr+3; // FIXME: is this offset correct for all modes?!
510
 
510
 
511
                if(gpb->propertyProcs->getPropertyProc){
511
                if(gpb->propertyProcs->getPropertyProc){
512
                        gpb->propertyProcs->getPropertyProc(kPhotoshopSignature,propWatchSuspension,0,&watchsusp,NULL);
512
                        gpb->propertyProcs->getPropertyProc(kPhotoshopSignature,propWatchSuspension,0,&watchsusp,NULL);
513
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp+1,NULL);
513
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp+1,NULL);
514
                }
514
                }
515
 
515
 
516
                e = gpb->displayPixels(&preview_pmap,&srcRect,imagebounds.top,imagebounds.left,hdc);
516
                e = gpb->displayPixels(&preview_pmap,&srcRect,imagebounds.top,imagebounds.left,hdc);
517
 
517
 
518
                if(gpb->propertyProcs->getPropertyProc)
518
                if(gpb->propertyProcs->getPropertyProc)
519
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp,NULL);
519
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp,NULL);
520
        }
520
        }
521
        return e;
521
        return e;
522
}
522
}