Subversion Repositories filter_foundry

Rev

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

Rev 503 Rev 526
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-2022 Daniel Marschall, ViaThinkSoft
4
    Copyright (C) 2018-2022 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
FFBuffer preview_handle;
37
FFBuffer 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
                newBuffer(&preview_handle, (long)preview_h * preview_pmap.rowBytes);
107
                newBuffer(&preview_handle, (long)preview_h * preview_pmap.rowBytes);
108
        }else
108
        }else
109
                preview_handle.signature = BUFVERSION_NULL;
109
                preview_handle.signature = BUFVERSION_NULL;
110
        return preview_handle.signature != BUFVERSION_NULL;
110
        return preview_handle.signature != BUFVERSION_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
        disposeBuffer(&preview_handle);
120
        disposeBuffer(&preview_handle);
121
}
121
}
122
 
122
 
123
void* memset_bgcolor(void* ptr, size_t num) {
123
void* memset_bgcolor(void* ptr, size_t num) {
124
        int i;
124
        int i;
125
        unsigned char* p;
125
        unsigned char* p;
126
 
126
 
127
        i = 0;
127
        i = 0;
128
        p = (unsigned char*)ptr;
128
        p = (unsigned char*)ptr;
129
        for (i=0; i<(int)num; ++i) {
129
        for (i=0; i<(int)num; ++i) {
130
                #ifdef WIN_ENV
130
                #ifdef WIN_ENV
131
                DWORD color;
131
                DWORD color;
132
 
132
 
133
                color = GetSysColor(COLOR_APPWORKSPACE);
133
                color = GetSysColor(COLOR_APPWORKSPACE);
134
 
134
 
135
                if (gpb->imageMode == plugInModeRGBColor) {
135
                if (gpb->imageMode == plugInModeRGBColor) {
136
                        if (i%nplanes == 0) p[i] = GetRValue(color);
136
                        if (i%nplanes == 0) p[i] = GetRValue(color);
137
                        if (i%nplanes == 1) p[i] = GetGValue(color);
137
                        if (i%nplanes == 1) p[i] = GetGValue(color);
138
                        if (i%nplanes == 2) p[i] = GetBValue(color);
138
                        if (i%nplanes == 2) p[i] = GetBValue(color);
139
                        if (i%nplanes == 3) p[i] = 255; // alpha channel
139
                        if (i%nplanes == 3) p[i] = 255; // alpha channel
140
                } else if (gpb->imageMode == plugInModeGrayScale) {
140
                } else if (gpb->imageMode == plugInModeGrayScale) {
141
                        uint8_t r, g, b;
141
                        uint8_t r, g, b;
142
 
142
 
143
                        r = GetRValue(color);
143
                        r = GetRValue(color);
144
                        g = GetGValue(color);
144
                        g = GetGValue(color);
145
                        b = GetBValue(color);
145
                        b = GetBValue(color);
146
 
146
 
147
                        if (i%nplanes == 0) p[i] = (uint8_t)(((299L*r)+(587L*g)+(114L*b))/1000);
147
                        if (i%nplanes == 0) p[i] = (uint8_t)(((299L*r)+(587L*g)+(114L*b))/1000);
148
                        if (i%nplanes == 1) p[i] = 255; // alpha channel
148
                        if (i%nplanes == 1) p[i] = 255; // alpha channel
149
                } else if (gpb->imageMode == plugInModeCMYKColor) {
149
                } else if (gpb->imageMode == plugInModeCMYKColor) {
150
                        uint8_t r, g, b;
150
                        uint8_t r, g, b;
151
                        double dmax, dr, dg, db, k, c, m, y;
151
                        double dmax, dr, dg, db, k, c, m, y;
152
 
152
 
153
                        r = GetRValue(color);
153
                        r = GetRValue(color);
154
                        g = GetGValue(color);
154
                        g = GetGValue(color);
155
                        b = GetBValue(color);
155
                        b = GetBValue(color);
156
 
156
 
157
                        dr = (double)r / 255;
157
                        dr = (double)r / 255;
158
                        dg = (double)g / 255;
158
                        dg = (double)g / 255;
159
                        db = (double)b / 255;
159
                        db = (double)b / 255;
160
 
160
 
161
                        dmax = dr;
161
                        dmax = dr;
162
                        if (dg>dmax) dmax = dg;
162
                        if (dg>dmax) dmax = dg;
163
                        if (db>dmax) dmax = db;
163
                        if (db>dmax) dmax = db;
164
 
164
 
165
                        k = 1 - dmax;
165
                        k = 1 - dmax;
166
                        c = (1 - dr - k) / (1 - k);
166
                        c = (1 - dr - k) / (1 - k);
167
                        m = (1 - dg - k) / (1 - k);
167
                        m = (1 - dg - k) / (1 - k);
168
                        y = (1 - db - k) / (1 - k);
168
                        y = (1 - db - k) / (1 - k);
169
 
169
 
170
                        if (i%nplanes == 0) p[i] = (uint8_t)(255 - c * 255);
170
                        if (i%nplanes == 0) p[i] = (uint8_t)(255 - c * 255);
171
                        if (i%nplanes == 1) p[i] = (uint8_t)(255 - m * 255);
171
                        if (i%nplanes == 1) p[i] = (uint8_t)(255 - m * 255);
172
                        if (i%nplanes == 2) p[i] = (uint8_t)(255 - y * 255);
172
                        if (i%nplanes == 2) p[i] = (uint8_t)(255 - y * 255);
173
                        if (i%nplanes == 3) p[i] = (uint8_t)(255 - k * 255);
173
                        if (i%nplanes == 3) p[i] = (uint8_t)(255 - k * 255);
174
                } else {
174
                } else {
175
                        // FIXME: If we are in such a non supported color mode, then
175
                        // FIXME: If we are in such a non supported color mode, then
176
                        //        these color codes would be all wrong!
176
                        //        these color codes would be all wrong!
177
                        //        Just to be safe use (what is probably) white
177
                        //        Just to be safe use (what is probably) white
178
                        p[i] = 0xFF;
178
                        p[i] = 0xFF;
179
 
179
 
180
                        /*
180
                        /*
181
                        #define plugInModeBitmap                        0
181
                        #define plugInModeBitmap                        0
182
                        #define plugInModeGrayScale                     1 supported
182
                        #define plugInModeGrayScale                     1 supported
183
                        #define plugInModeIndexedColor          2
183
                        #define plugInModeIndexedColor          2
184
                        #define plugInModeRGBColor                      3 supported
184
                        #define plugInModeRGBColor                      3 supported
185
                        #define plugInModeCMYKColor                     4 supported
185
                        #define plugInModeCMYKColor                     4 supported
186
                        #define plugInModeHSLColor                      5
186
                        #define plugInModeHSLColor                      5
187
                        #define plugInModeHSBColor                      6
187
                        #define plugInModeHSBColor                      6
188
                        #define plugInModeMultichannel          7
188
                        #define plugInModeMultichannel          7
189
                        #define plugInModeDuotone                       8
189
                        #define plugInModeDuotone                       8
190
                        #define plugInModeLabColor                      9
190
                        #define plugInModeLabColor                      9
191
                        #define plugInModeGray16                        10
191
                        #define plugInModeGray16                        10
192
                        #define plugInModeRGB48                         11
192
                        #define plugInModeRGB48                         11
193
                        #define plugInModeLab48                         12
193
                        #define plugInModeLab48                         12
194
                        #define plugInModeCMYK64                        13
194
                        #define plugInModeCMYK64                        13
195
                        #define plugInModeDeepMultichannel      14
195
                        #define plugInModeDeepMultichannel      14
196
                        #define plugInModeDuotone16                     15
196
                        #define plugInModeDuotone16                     15
197
                        #define plugInModeRGB96                         16
197
                        #define plugInModeRGB96                         16
198
                        #define plugInModeGray32                        17
198
                        #define plugInModeGray32                        17
199
                        */
199
                        */
200
 
200
 
201
                }
201
                }
202
                #else
202
                #else
203
                // This is the behavior of FilterFoundry <1.7 was this (filled with 0xFF)
203
                // This is the behavior of FilterFoundry <1.7 was this (filled with 0xFF)
204
                // FIXME: Should we do something fancy here, too?
204
                // FIXME: Should we do something fancy here, too?
205
                p[i] = 0xFF;
205
                p[i] = 0xFF;
206
                #endif
206
                #endif
207
        }
207
        }
208
        return ptr;
208
        return ptr;
209
}
209
}
210
 
210
 
211
void recalc_preview_olddoc(FilterRecordPtr pb, DIALOGREF dp) {
211
void recalc_preview_olddoc(FilterRecordPtr pb, DIALOGREF dp) {
212
        OSErr e;
212
        OSErr e;
213
        double scaledw, scaledh;
213
        double scaledw, scaledh;
214
        int j, n, imgw, imgh;
214
        int j, n, imgw, imgh;
215
        Rect r, outRect;
215
        Rect r, outRect;
216
        Ptr outrow;
216
        Ptr outrow;
217
 
217
 
218
        preview_complete = false;
218
        preview_complete = false;
219
 
219
 
220
        if (preview_handle.signature != BUFVERSION_NULL) {
220
        if (preview_handle.signature != BUFVERSION_NULL) {
221
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
221
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
222
                scaledw = zoomfactor * preview_w;
222
                scaledw = zoomfactor * preview_w;
223
                if (scaledw > ((double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left))
223
                if (scaledw > ((double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left))
224
                        scaledw = (double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left;
224
                        scaledw = (double)FILTER_RECT(pb).right - (double)FILTER_RECT(pb).left;
225
                scaledh = zoomfactor * preview_h;
225
                scaledh = zoomfactor * preview_h;
226
                if (scaledh > ((double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top))
226
                if (scaledh > ((double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top))
227
                        scaledh = (double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top;
227
                        scaledh = (double)FILTER_RECT(pb).bottom - (double)FILTER_RECT(pb).top;
228
 
228
 
229
                /* scale clipped preview area down again - this becomes the pixel size of preview */
229
                /* scale clipped preview area down again - this becomes the pixel size of preview */
230
                imgw = (int)ceil(scaledw / zoomfactor);
230
                imgw = (int)ceil(scaledw / zoomfactor);
231
                if (imgw > preview_w)
231
                if (imgw > preview_w)
232
                        imgw = preview_w;
232
                        imgw = preview_w;
233
                imgh = (int)ceil(scaledh / zoomfactor);
233
                imgh = (int)ceil(scaledh / zoomfactor);
234
                if (imgh > preview_h)
234
                if (imgh > preview_h)
235
                        imgh = preview_h;
235
                        imgh = preview_h;
236
 
236
 
237
                /* compute source data rectangle (inRect) */
237
                /* compute source data rectangle (inRect) */
238
 
238
 
239
                /* centre preview on filtered part of input image, adding scroll offset */
239
                /* centre preview on filtered part of input image, adding scroll offset */
240
                r.left = (int16)(((double)FILTER_RECT(pb).left + (double)FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
240
                r.left = (int16)(((double)FILTER_RECT(pb).left + (double)FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
241
                /* make sure it does not go outside the input area */
241
                /* make sure it does not go outside the input area */
242
                if (r.left < FILTER_RECT(pb).left) {
242
                if (r.left < FILTER_RECT(pb).left) {
243
                        preview_scroll.h += FILTER_RECT(pb).left - r.left;
243
                        preview_scroll.h += FILTER_RECT(pb).left - r.left;
244
                        r.left = FILTER_RECT(pb).left;
244
                        r.left = FILTER_RECT(pb).left;
245
                }
245
                }
246
                else if ((double)r.left + scaledw > FILTER_RECT(pb).right) {
246
                else if ((double)r.left + scaledw > FILTER_RECT(pb).right) {
247
                        preview_scroll.h += (int16)((double)FILTER_RECT(pb).right - ((double)r.left + scaledw));
247
                        preview_scroll.h += (int16)((double)FILTER_RECT(pb).right - ((double)r.left + scaledw));
248
                        r.left = (int16)((double)FILTER_RECT(pb).right - scaledw);
248
                        r.left = (int16)((double)FILTER_RECT(pb).right - scaledw);
249
                }
249
                }
250
                r.right = (int16)((double)r.left + scaledw);
250
                r.right = (int16)((double)r.left + scaledw);
251
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
251
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
252
 
252
 
253
                /* now compute for vertical */
253
                /* now compute for vertical */
254
                r.top = (int16)(((double)FILTER_RECT(pb).top + (double)FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
254
                r.top = (int16)(((double)FILTER_RECT(pb).top + (double)FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
255
                if (r.top < FILTER_RECT(pb).top) {
255
                if (r.top < FILTER_RECT(pb).top) {
256
                        preview_scroll.v += FILTER_RECT(pb).top - r.top;
256
                        preview_scroll.v += FILTER_RECT(pb).top - r.top;
257
                        r.top = FILTER_RECT(pb).top;
257
                        r.top = FILTER_RECT(pb).top;
258
                }
258
                }
259
                else if ((double)r.top + scaledh > FILTER_RECT(pb).bottom) {
259
                else if ((double)r.top + scaledh > FILTER_RECT(pb).bottom) {
260
                        preview_scroll.v += (int16)(FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
260
                        preview_scroll.v += (int16)(FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
261
                        r.top = (int16)((double)FILTER_RECT(pb).bottom - scaledh);
261
                        r.top = (int16)((double)FILTER_RECT(pb).bottom - scaledh);
262
                }
262
                }
263
                r.bottom = (int16)((double)r.top + scaledh);
263
                r.bottom = (int16)((double)r.top + scaledh);
264
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
264
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
265
 
265
 
266
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
266
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
267
                if (needall)
267
                if (needall)
268
                        SETRECT(IN_RECT(pb), 0, 0, IMAGE_SIZE(pb).h, IMAGE_SIZE(pb).v);
268
                        SETRECT(IN_RECT(pb), 0, 0, IMAGE_SIZE(pb).h, IMAGE_SIZE(pb).v);
269
                else
269
                else
270
                        IN_RECT(pb) = r;
270
                        IN_RECT(pb) = r;
271
 
271
 
272
                OUT_RECT(pb) = IN_RECT(pb);
272
                OUT_RECT(pb) = IN_RECT(pb);
273
                SETRECT(MASK_RECT(pb), 0, 0, 0, 0);
273
                SETRECT(MASK_RECT(pb), 0, 0, 0, 0);
274
                pb->inLoPlane = pb->outLoPlane = 0;
274
                pb->inLoPlane = pb->outLoPlane = 0;
275
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
275
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
276
 
276
 
277
                if (!needinput || !(e = pb->advanceState())) {
277
                if (!needinput || !(e = pb->advanceState())) {
278
                        Ptr outptr = lockBuffer(&preview_handle);
278
                        Ptr outptr = lockBuffer(&preview_handle);
279
                        int blankrows = (preview_h - imgh) / 2,
279
                        int blankrows = (preview_h - imgh) / 2,
280
                            blankcols = (preview_w - imgw) / 2,
280
                            blankcols = (preview_w - imgw) / 2,
281
                            pmrb = preview_pmap.rowBytes;
281
                            pmrb = preview_pmap.rowBytes;
282
 
282
 
283
                        evalinit();
283
                        evalinit();
284
 
284
 
285
                        SETRECT(outRect, 0, 0, imgw, imgh);
285
                        SETRECT(outRect, 0, 0, imgw, imgh);
286
 
286
 
287
                        e = process_scaled_olddoc(pb, false, r, outRect,
287
                        e = process_scaled_olddoc(pb, false, r, outRect,
288
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
288
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
289
                        if (blankrows) {
289
                        if (blankrows) {
290
                                // blank rows on top of preview:
290
                                // blank rows on top of preview:
291
                                memset_bgcolor(outptr, pmrb * blankrows);
291
                                memset_bgcolor(outptr, pmrb * blankrows);
292
                                // blank rows below preview:
292
                                // blank rows below preview:
293
                                n = preview_h - blankrows - imgh;
293
                                n = preview_h - blankrows - imgh;
294
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
294
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
295
                        }
295
                        }
296
                        if (blankcols) {
296
                        if (blankcols) {
297
                                n = preview_w - blankcols - imgw;
297
                                n = preview_w - blankcols - imgw;
298
                                outrow = outptr + pmrb * blankrows;
298
                                outrow = outptr + pmrb * blankrows;
299
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
299
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
300
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
300
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
301
                                        memset_bgcolor(outrow, nplanes * blankcols);
301
                                        memset_bgcolor(outrow, nplanes * blankcols);
302
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
302
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
303
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
303
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
304
                                        outrow += pmrb;
304
                                        outrow += pmrb;
305
                                }
305
                                }
306
                        }
306
                        }
307
 
307
 
308
                        if (e == noErr) {
308
                        if (e == noErr) {
309
                                preview_complete = true;
309
                                preview_complete = true;
310
 
310
 
311
                                #ifdef WIN_ENV
311
                                #ifdef WIN_ENV
312
                                {
312
                                {
313
                                        extern HWND preview_hwnd;
313
                                        extern HWND preview_hwnd;
314
                                        HDC hdc = GetDC(preview_hwnd);
314
                                        HDC hdc = GetDC(preview_hwnd);
315
 
315
 
316
                                        drawpreview(dp, hdc, outptr);
316
                                        drawpreview(dp, hdc, outptr);
317
 
317
 
318
                                        ReleaseDC(preview_hwnd, hdc);
318
                                        ReleaseDC(preview_hwnd, hdc);
319
                                }
319
                                }
320
                                #else
320
                                #else
321
                                {
321
                                {
322
                                        GrafPtr saveport;
322
                                        GrafPtr saveport;
323
 
323
 
324
                                        GetPort(&saveport);
324
                                        GetPort(&saveport);
325
                                        SetPortDialogPort(dp);
325
                                        SetPortDialogPort(dp);
326
 
326
 
327
                                        drawpreview(dp, NULL, outptr);
327
                                        drawpreview(dp, NULL, outptr);
328
 
328
 
329
                                        SetPort(saveport);
329
                                        SetPort(saveport);
330
                                }
330
                                }
331
                                #endif
331
                                #endif
332
                        }
332
                        }
333
 
333
 
334
                        unlockBuffer(&preview_handle);
334
                        unlockBuffer(&preview_handle);
335
                }
335
                }
336
 
336
 
337
                if (e && !previewerr) {
337
                if (e && !previewerr) {
338
                        simplealert_id(e == memFullErr && !needall ? MSG_CANNOT_ZOOM_MEMFULL_ID : MSG_CANNOT_ZOOM_ID);
338
                        simplealert_id(e == memFullErr && !needall ? MSG_CANNOT_ZOOM_MEMFULL_ID : MSG_CANNOT_ZOOM_ID);
339
                        previewerr = true;
339
                        previewerr = true;
340
                }
340
                }
341
 
341
 
342
        }
342
        }
343
}
343
}
344
 
344
 
345
void recalc_preview_bigdoc(FilterRecordPtr pb, DIALOGREF dp) {
345
void recalc_preview_bigdoc(FilterRecordPtr pb, DIALOGREF dp) {
346
        OSErr e;
346
        OSErr e;
347
        double scaledw, scaledh;
347
        double scaledw, scaledh;
348
        int j, n, imgw, imgh;
348
        int j, n, imgw, imgh;
349
        VRect r, outRect;
349
        VRect r, outRect;
350
        Ptr outrow;
350
        Ptr outrow;
351
 
351
 
352
        preview_complete = false;
352
        preview_complete = false;
353
 
353
 
354
        if (preview_handle.signature != BUFVERSION_NULL) {
354
        if (preview_handle.signature != BUFVERSION_NULL) {
355
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
355
                /* size of previewed area, of source image; but no larger than filtered area (selection) */
356
                scaledw = zoomfactor * preview_w;
356
                scaledw = zoomfactor * preview_w;
357
                if (scaledw > ((double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left))
357
                if (scaledw > ((double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left))
358
                        scaledw = (double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left;
358
                        scaledw = (double)BIGDOC_FILTER_RECT(pb).right - (double)BIGDOC_FILTER_RECT(pb).left;
359
                scaledh = zoomfactor * preview_h;
359
                scaledh = zoomfactor * preview_h;
360
                if (scaledh > ((double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top))
360
                if (scaledh > ((double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top))
361
                        scaledh = (double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top;
361
                        scaledh = (double)BIGDOC_FILTER_RECT(pb).bottom - (double)BIGDOC_FILTER_RECT(pb).top;
362
 
362
 
363
                /* scale clipped preview area down again - this becomes the pixel size of preview */
363
                /* scale clipped preview area down again - this becomes the pixel size of preview */
364
                imgw = (int)ceil(scaledw / zoomfactor);
364
                imgw = (int)ceil(scaledw / zoomfactor);
365
                if (imgw > preview_w)
365
                if (imgw > preview_w)
366
                        imgw = preview_w;
366
                        imgw = preview_w;
367
                imgh = (int)ceil(scaledh / zoomfactor);
367
                imgh = (int)ceil(scaledh / zoomfactor);
368
                if (imgh > preview_h)
368
                if (imgh > preview_h)
369
                        imgh = preview_h;
369
                        imgh = preview_h;
370
 
370
 
371
                /* compute source data rectangle (inRect) */
371
                /* compute source data rectangle (inRect) */
372
 
372
 
373
                /* centre preview on filtered part of input image, adding scroll offset */
373
                /* centre preview on filtered part of input image, adding scroll offset */
374
                r.left = (int32)(((double)BIGDOC_FILTER_RECT(pb).left + (double)BIGDOC_FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
374
                r.left = (int32)(((double)BIGDOC_FILTER_RECT(pb).left + (double)BIGDOC_FILTER_RECT(pb).right - scaledw) / 2 + preview_scroll.h);
375
                /* make sure it does not go outside the input area */
375
                /* make sure it does not go outside the input area */
376
                if (r.left < BIGDOC_FILTER_RECT(pb).left) {
376
                if (r.left < BIGDOC_FILTER_RECT(pb).left) {
377
                        preview_scroll.h += BIGDOC_FILTER_RECT(pb).left - r.left;
377
                        preview_scroll.h += BIGDOC_FILTER_RECT(pb).left - r.left;
378
                        r.left = BIGDOC_FILTER_RECT(pb).left;
378
                        r.left = BIGDOC_FILTER_RECT(pb).left;
379
                }
379
                }
380
                else if ((double)r.left + scaledw > BIGDOC_FILTER_RECT(pb).right) {
380
                else if ((double)r.left + scaledw > BIGDOC_FILTER_RECT(pb).right) {
381
                        preview_scroll.h += (int32)((double)BIGDOC_FILTER_RECT(pb).right - ((double)r.left + scaledw));
381
                        preview_scroll.h += (int32)((double)BIGDOC_FILTER_RECT(pb).right - ((double)r.left + scaledw));
382
                        r.left = (int32)((double)BIGDOC_FILTER_RECT(pb).right - scaledw);
382
                        r.left = (int32)((double)BIGDOC_FILTER_RECT(pb).right - scaledw);
383
                }
383
                }
384
                r.right = (int32)((double)r.left + scaledw);
384
                r.right = (int32)((double)r.left + scaledw);
385
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
385
                preview_pmap.maskPhaseCol = (int32)((preview_scroll.h) / zoomfactor); // phase of the checkerboard
386
 
386
 
387
                /* now compute for vertical */
387
                /* now compute for vertical */
388
                r.top = (int32)(((double)BIGDOC_FILTER_RECT(pb).top + (double)BIGDOC_FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
388
                r.top = (int32)(((double)BIGDOC_FILTER_RECT(pb).top + (double)BIGDOC_FILTER_RECT(pb).bottom - scaledh) / 2 + preview_scroll.v);
389
                if (r.top < BIGDOC_FILTER_RECT(pb).top) {
389
                if (r.top < BIGDOC_FILTER_RECT(pb).top) {
390
                        preview_scroll.v += BIGDOC_FILTER_RECT(pb).top - r.top;
390
                        preview_scroll.v += BIGDOC_FILTER_RECT(pb).top - r.top;
391
                        r.top = BIGDOC_FILTER_RECT(pb).top;
391
                        r.top = BIGDOC_FILTER_RECT(pb).top;
392
                }
392
                }
393
                else if ((double)r.top + scaledh > BIGDOC_FILTER_RECT(pb).bottom) {
393
                else if ((double)r.top + scaledh > BIGDOC_FILTER_RECT(pb).bottom) {
394
                        preview_scroll.v += (int32)(BIGDOC_FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
394
                        preview_scroll.v += (int32)(BIGDOC_FILTER_RECT(pb).bottom - ((double)r.top + scaledh));
395
                        r.top = (int32)((double)BIGDOC_FILTER_RECT(pb).bottom - scaledh);
395
                        r.top = (int32)((double)BIGDOC_FILTER_RECT(pb).bottom - scaledh);
396
                }
396
                }
397
                r.bottom = (int32)((double)r.top + scaledh);
397
                r.bottom = (int32)((double)r.top + scaledh);
398
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
398
                preview_pmap.maskPhaseRow = (int32)((preview_scroll.v) / zoomfactor); // phase of the checkerboard
399
 
399
 
400
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
400
                /* if formulae need random access to image - src(), rad() - we must request entire area: */
401
                if (needall)
401
                if (needall)
402
                        SETRECT(BIGDOC_IN_RECT(pb), 0, 0, BIGDOC_IMAGE_SIZE(pb).h, BIGDOC_IMAGE_SIZE(pb).v);
402
                        SETRECT(BIGDOC_IN_RECT(pb), 0, 0, BIGDOC_IMAGE_SIZE(pb).h, BIGDOC_IMAGE_SIZE(pb).v);
403
                else
403
                else
404
                        BIGDOC_IN_RECT(pb) = r;
404
                        BIGDOC_IN_RECT(pb) = r;
405
 
405
 
406
                BIGDOC_OUT_RECT(pb) = BIGDOC_IN_RECT(pb);
406
                BIGDOC_OUT_RECT(pb) = BIGDOC_IN_RECT(pb);
407
                SETRECT(BIGDOC_MASK_RECT(pb), 0, 0, 0, 0);
407
                SETRECT(BIGDOC_MASK_RECT(pb), 0, 0, 0, 0);
408
                pb->inLoPlane = pb->outLoPlane = 0;
408
                pb->inLoPlane = pb->outLoPlane = 0;
409
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
409
                pb->inHiPlane = pb->outHiPlane = nplanes - 1;
410
 
410
 
411
                if (!needinput || !(e = pb->advanceState())) {
411
                if (!needinput || !(e = pb->advanceState())) {
412
                        Ptr outptr = lockBuffer(&preview_handle);
412
                        Ptr outptr = lockBuffer(&preview_handle);
413
                        int blankrows = (preview_h - imgh) / 2,
413
                        int blankrows = (preview_h - imgh) / 2,
414
                            blankcols = (preview_w - imgw) / 2,
414
                            blankcols = (preview_w - imgw) / 2,
415
                            pmrb = preview_pmap.rowBytes;
415
                            pmrb = preview_pmap.rowBytes;
416
 
416
 
417
                        evalinit();
417
                        evalinit();
418
 
418
 
419
                        SETRECT(outRect, 0, 0, imgw, imgh);
419
                        SETRECT(outRect, 0, 0, imgw, imgh);
420
 
420
 
421
                        e = process_scaled_bigdoc(pb, false, r, outRect,
421
                        e = process_scaled_bigdoc(pb, false, r, outRect,
422
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
422
                                outptr + pmrb * blankrows + nplanes * blankcols, pmrb, zoomfactor);
423
                        if (blankrows) {
423
                        if (blankrows) {
424
                                // blank rows on top of preview:
424
                                // blank rows on top of preview:
425
                                memset_bgcolor(outptr, pmrb * blankrows);
425
                                memset_bgcolor(outptr, pmrb * blankrows);
426
                                // blank rows below preview:
426
                                // blank rows below preview:
427
                                n = preview_h - blankrows - imgh;
427
                                n = preview_h - blankrows - imgh;
428
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
428
                                memset_bgcolor(outptr + pmrb * (blankrows + imgh), pmrb * n);
429
                        }
429
                        }
430
                        if (blankcols) {
430
                        if (blankcols) {
431
                                n = preview_w - blankcols - imgw;
431
                                n = preview_w - blankcols - imgw;
432
                                outrow = outptr + pmrb * blankrows;
432
                                outrow = outptr + pmrb * blankrows;
433
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
433
                                for (j = blankrows; j < preview_h - blankrows; ++j) {
434
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
434
                                        // blank columns on left side of preview (if picture is smaller than the preview area):
435
                                        memset_bgcolor(outrow, nplanes * blankcols);
435
                                        memset_bgcolor(outrow, nplanes * blankcols);
436
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
436
                                        // blank columns on right side of preview (if picture is smaller than the preview area):
437
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
437
                                        memset_bgcolor(outrow + nplanes * (blankcols + imgw), nplanes * n);
438
                                        outrow += pmrb;
438
                                        outrow += pmrb;
439
                                }
439
                                }
440
                        }
440
                        }
441
 
441
 
442
                        if (e == noErr) {
442
                        if (e == noErr) {
443
                                preview_complete = true;
443
                                preview_complete = true;
444
 
444
 
445
                                #ifdef WIN_ENV
445
                                #ifdef WIN_ENV
446
                                {
446
                                {
447
                                        extern HWND preview_hwnd;
447
                                        extern HWND preview_hwnd;
448
                                        HDC hdc = GetDC(preview_hwnd);
448
                                        HDC hdc = GetDC(preview_hwnd);
449
 
449
 
450
                                        drawpreview(dp, hdc, outptr);
450
                                        drawpreview(dp, hdc, outptr);
451
 
451
 
452
                                        ReleaseDC(preview_hwnd, hdc);
452
                                        ReleaseDC(preview_hwnd, hdc);
453
                                }
453
                                }
454
                                #else
454
                                #else
455
                                {
455
                                {
456
                                        GrafPtr saveport;
456
                                        GrafPtr saveport;
457
 
457
 
458
                                        GetPort(&saveport);
458
                                        GetPort(&saveport);
459
                                        SetPortDialogPort(dp);
459
                                        SetPortDialogPort(dp);
460
 
460
 
461
                                        drawpreview(dp, NULL, outptr);
461
                                        drawpreview(dp, NULL, outptr);
462
 
462
 
463
                                        SetPort(saveport);
463
                                        SetPort(saveport);
464
                                }
464
                                }
465
                                #endif
465
                                #endif
466
                        }
466
                        }
467
 
467
 
468
                        unlockBuffer(&preview_handle);
468
                        unlockBuffer(&preview_handle);
469
                }
469
                }
470
 
470
 
471
                if (e && !previewerr) {
471
                if (e && !previewerr) {
472
                        simplealert_id(e == memFullErr && !needall ? MSG_CANNOT_ZOOM_MEMFULL_ID : MSG_CANNOT_ZOOM_ID);
472
                        simplealert_id(e == memFullErr && !needall ? MSG_CANNOT_ZOOM_MEMFULL_ID : MSG_CANNOT_ZOOM_ID);
473
                        previewerr = true;
473
                        previewerr = true;
474
                }
474
                }
475
 
475
 
476
        }
476
        }
477
}
477
}
478
 
478
 
479
void recalc_preview(FilterRecordPtr pb, DIALOGREF dp) {
479
void recalc_preview(FilterRecordPtr pb, DIALOGREF dp) {
480
        // TODO? When a formula has an error, the preview should not be changeable
480
        // TODO? When a formula has an error, the preview should not be changeable
481
        // (This code does not work because you can still try to zoom)
481
        // (This code does not work because you can still try to zoom)
482
        /*
482
        /*
483
        if (!gdata->standalone) {
483
        if (!gdata->standalone) {
484
                int i;
484
                int i;
485
                for (i = 0; i < 4; i++)
485
                for (i = 0; i < 4; i++)
486
                        if (!parseexpr(expr[i])) return;
486
                        if (!parseexpr(expr[i])) return;
487
        }
487
        }
488
        */
488
        */
489
 
489
 
490
        if (HAS_BIG_DOC(pb)) {
490
        if (HAS_BIG_DOC(pb)) {
491
                recalc_preview_bigdoc(pb, dp);
491
                recalc_preview_bigdoc(pb, dp);
492
        }
492
        }
493
        else {
493
        else {
494
                recalc_preview_olddoc(pb, dp);
494
                recalc_preview_olddoc(pb, dp);
495
        }
495
        }
496
}
496
}
497
 
497
 
498
OSErr drawpreview(DIALOGREF dp,void *hdc,Ptr imageptr){
498
OSErr drawpreview(DIALOGREF dp,void *hdc,Ptr imageptr){
499
        intptr_t watchsusp;
499
        intptr_t watchsusp;
500
        OSErr e = noErr;
500
        OSErr e = noErr;
501
        VRect srcRect;
501
        VRect srcRect;
502
        UIRECT imagebounds;
502
        UIRECT imagebounds;
503
 
503
 
504
        UNREFERENCED_PARAMETER(dp);
504
        UNREFERENCED_PARAMETER(dp);
505
 
505
 
506
        if((preview_handle.signature != BUFVERSION_NULL) && preview_complete){
506
        if((preview_handle.signature != BUFVERSION_NULL) && preview_complete){
507
 
507
 
508
                srcRect = preview_pmap.bounds;
508
                srcRect = preview_pmap.bounds;
509
 
509
 
510
                imagebounds.left = (preview_rect.left + preview_rect.right - preview_w)/2;
510
                imagebounds.left = (preview_rect.left + preview_rect.right - preview_w)/2;
511
                imagebounds.top = (preview_rect.top + preview_rect.bottom - preview_h)/2;
511
                imagebounds.top = (preview_rect.top + preview_rect.bottom - preview_h)/2;
512
                imagebounds.right = imagebounds.left + preview_w;
512
                imagebounds.right = imagebounds.left + preview_w;
513
                imagebounds.bottom = imagebounds.top + preview_h;
513
                imagebounds.bottom = imagebounds.top + preview_h;
514
 
514
 
515
                preview_pmap.baseAddr = imageptr;
515
                preview_pmap.baseAddr = imageptr;
516
                preview_pmask.maskData = imageptr+3; // FIXME: is this offset correct for all modes?!
516
                preview_pmask.maskData = imageptr+3; // FIXME: is this offset correct for all modes?!
517
 
517
 
518
                if((gpb->propertyProcs != NULL) && gpb->propertyProcs->getPropertyProc){
518
                if((gpb->propertyProcs != NULL) && gpb->propertyProcs->getPropertyProc){
519
                        gpb->propertyProcs->getPropertyProc(kPhotoshopSignature,propWatchSuspension,0,&watchsusp,NULL);
519
                        gpb->propertyProcs->getPropertyProc(kPhotoshopSignature,propWatchSuspension,0,&watchsusp,NULL);
520
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp+1,NULL);
520
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp+1,NULL);
521
                }
521
                }
522
 
522
 
523
                e = gpb->displayPixels(&preview_pmap,&srcRect,imagebounds.top,imagebounds.left,hdc);
523
                e = gpb->displayPixels(&preview_pmap,&srcRect,imagebounds.top,imagebounds.left,hdc);
524
 
524
 
525
                if((gpb->propertyProcs != NULL) && gpb->propertyProcs->getPropertyProc)
525
                if((gpb->propertyProcs != NULL) && gpb->propertyProcs->getPropertyProc)
526
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp,NULL);
526
                        gpb->propertyProcs->setPropertyProc(kPhotoshopSignature,propWatchSuspension,0,watchsusp,NULL);
527
        }
527
        }
528
        return e;
528
        return e;
529
}
529
}
530
 
530