Rev 206 | Rev 235 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 206 | Rev 232 | ||
---|---|---|---|
Line 59... | Line 59... | ||
59 | // full setup for evaluation, called when formulae have changed. |
59 | // full setup for evaluation, called when formulae have changed. |
60 | Boolean setup(FilterRecordPtr pb){ |
60 | Boolean setup(FilterRecordPtr pb){ |
61 | int i; |
61 | int i; |
62 | 62 | ||
63 | // Attention: If you introduce new variables, please define them also in lexer.l |
63 | // Attention: If you introduce new variables, please define them also in lexer.l |
- | 64 | if (HAS_BIG_DOC(pb)) { |
|
- | 65 | var['X'] = BIGDOC_FILTER_RECT(pb).right - BIGDOC_FILTER_RECT(pb).left; |
|
- | 66 | var['Y'] = BIGDOC_FILTER_RECT(pb).bottom - BIGDOC_FILTER_RECT(pb).top; |
|
- | 67 | } else { |
|
64 | var['X'] = pb->filterRect.right - pb->filterRect.left; |
68 | var['X'] = FILTER_RECT(pb).right - FILTER_RECT(pb).left; |
65 | var['Y'] = pb->filterRect.bottom - pb->filterRect.top; |
69 | var['Y'] = FILTER_RECT(pb).bottom - FILTER_RECT(pb).top; |
- | 70 | } |
|
66 | var['Z'] = nplanes; |
71 | var['Z'] = nplanes; |
67 | var['D'] = 1024; |
72 | var['D'] = 1024; |
68 | var['M'] = ff_c2m(var['X'],var['Y'])/2; |
73 | var['M'] = ff_c2m(var['X'],var['Y'])/2; |
69 | 74 | ||
70 | /* initialise flags for tracking special variable usage */ |
75 | /* initialise flags for tracking special variable usage */ |
Line 158... | Line 163... | ||
158 | * e.g. 2.0 means 1 output pixel per 2 input pixels. |
163 | * e.g. 2.0 means 1 output pixel per 2 input pixels. |
159 | */ |
164 | */ |
160 | 165 | ||
161 | //#define PROCESS_SCALED_GAP_DEBUG 1 |
166 | //#define PROCESS_SCALED_GAP_DEBUG 1 |
162 | 167 | ||
163 | OSErr process_scaled(FilterRecordPtr pb, Boolean progress, |
168 | OSErr process_scaled_bigdoc(FilterRecordPtr pb, Boolean progress, |
164 | Rect *filterPiece, Rect *outPiece, |
169 | VRect filterPiece, VRect outPiece, |
165 | void *outData, long outRowBytes, double zoom){ |
170 | void *outData, long outRowBytes, double zoom){ |
166 | unsigned char *inrow,*outrow,*outp; |
171 | unsigned char *inrow,*outrow,*outp; |
167 | int j,i; |
172 | int j,i; |
168 | long t,ticks = TICKCOUNT(); |
173 | long t,ticks = TICKCOUNT(); |
169 | double x,y,k; |
174 | double x,y,k; |
Line 172... | Line 177... | ||
172 | char s[0x200]; |
177 | char s[0x200]; |
173 | int last_good_x, last_good_y; |
178 | int last_good_x, last_good_y; |
174 | last_good_y = -1; |
179 | last_good_y = -1; |
175 | #endif |
180 | #endif |
176 | 181 | ||
- | 182 | VRect filterRect; |
|
- | 183 | VRect inRect; |
|
- | 184 | ||
- | 185 | if (HAS_BIG_DOC(pb)) { |
|
- | 186 | filterRect = BIGDOC_FILTER_RECT(pb); |
|
- | 187 | inRect = BIGDOC_IN_RECT(pb); |
|
- | 188 | } else { |
|
- | 189 | filterRect.bottom = FILTER_RECT(pb).bottom; |
|
- | 190 | filterRect.left = FILTER_RECT(pb).left; |
|
- | 191 | filterRect.right = FILTER_RECT(pb).right; |
|
- | 192 | filterRect.top = FILTER_RECT(pb).top; |
|
- | 193 | inRect.bottom = IN_RECT(pb).bottom; |
|
- | 194 | inRect.left = IN_RECT(pb).left; |
|
- | 195 | inRect.right = IN_RECT(pb).right; |
|
- | 196 | inRect.top = IN_RECT(pb).top; |
|
- | 197 | } |
|
- | 198 | ||
177 | // find base pointer to selection image data |
199 | // find base pointer to selection image data |
178 | image_ptr = (unsigned char*)pb->inData |
200 | image_ptr = (unsigned char*)pb->inData |
179 | + (long)pb->inRowBytes*(pb->filterRect.top - pb->inRect.top) |
201 | + (long)pb->inRowBytes*(filterRect.top - inRect.top) |
180 | + (long)nplanes*(pb->filterRect.left - pb->inRect.left); |
202 | + (long)nplanes*(filterRect.left - inRect.left); |
181 | 203 | ||
182 | if (state_changing_funcs_used) { |
204 | if (state_changing_funcs_used) { |
183 | // Fill gap between selection/filter top border and top preview zoomed border |
205 | // Fill gap between selection/filter top border and top preview zoomed border |
184 | for (y = 0; y < filterPiece->top - pb->filterRect.top; ++y) { |
206 | for (y = 0; y < (double)filterPiece.top - (double)filterRect.top; ++y) { |
185 | #ifdef PROCESS_SCALED_GAP_DEBUG |
207 | #ifdef PROCESS_SCALED_GAP_DEBUG |
186 | if (state_changing_funcs_used && last_good_y != (int)floor(y-1)) { sprintf(s, "Non calculated Y gap, type 1: %f, last good %d, zoom %f\n", y, last_good_y, zoom); simplealert(s); } last_good_y = (int)floor(y); |
208 | if (state_changing_funcs_used && last_good_y != (int)floor(y-1)) { sprintf(s, "Non calculated Y gap, type 1: %f, last good %d, zoom %f\n", y, last_good_y, zoom); simplealert(s); } last_good_y = (int)floor(y); |
187 | #endif |
209 | #endif |
188 | 210 | ||
189 | var['y'] = (value_type)y; |
211 | var['y'] = (value_type)y; |
Line 191... | Line 213... | ||
191 | 213 | ||
192 | #ifdef PROCESS_SCALED_GAP_DEBUG |
214 | #ifdef PROCESS_SCALED_GAP_DEBUG |
193 | last_good_x = -1; |
215 | last_good_x = -1; |
194 | #endif |
216 | #endif |
195 | 217 | ||
196 | for (x = 0; x < pb->filterRect.right - pb->filterRect.left; ++x) { |
218 | for (x = 0; x < (double)filterRect.right - (double)filterRect.left; ++x) { |
197 | #ifdef PROCESS_SCALED_GAP_DEBUG |
219 | #ifdef PROCESS_SCALED_GAP_DEBUG |
198 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 1a: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
220 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 1a: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
199 | #endif |
221 | #endif |
200 | 222 | ||
201 | var['x'] = (value_type)x; |
223 | var['x'] = (value_type)x; |
Line 207... | Line 229... | ||
207 | #endif |
229 | #endif |
208 | } |
230 | } |
209 | } |
231 | } |
210 | 232 | ||
211 | // j indexes scaled output rows |
233 | // j indexes scaled output rows |
212 | for( j = outPiece->top, outrow = (unsigned char*)outData, y = filterPiece->top - pb->filterRect.top ; |
234 | for( j = outPiece.top, outrow = (unsigned char*)outData, y = (double)filterPiece.top - (double)filterRect.top ; |
213 | j < outPiece->bottom ; ++j, outrow += outRowBytes, y += zoom ) |
235 | j < outPiece.bottom ; ++j, outrow += outRowBytes, y += zoom ) |
214 | { |
236 | { |
215 | #ifdef PROCESS_SCALED_GAP_DEBUG |
237 | #ifdef PROCESS_SCALED_GAP_DEBUG |
216 | if (state_changing_funcs_used && last_good_y != (int)floor(y-1)) { sprintf(s, "Non calculated Y gap, type 1: %f, last good %d, zoom %f\n", y, last_good_y, zoom); simplealert(s); } last_good_y = (int)floor(y); |
238 | if (state_changing_funcs_used && last_good_y != (int)floor(y-1)) { sprintf(s, "Non calculated Y gap, type 1: %f, last good %d, zoom %f\n", y, last_good_y, zoom); simplealert(s); } last_good_y = (int)floor(y); |
217 | #endif |
239 | #endif |
218 | 240 | ||
Line 223... | Line 245... | ||
223 | last_good_x = -1; |
245 | last_good_x = -1; |
224 | #endif |
246 | #endif |
225 | 247 | ||
226 | if (state_changing_funcs_used) { |
248 | if (state_changing_funcs_used) { |
227 | // Fill gap between left selection/image border and left border of the preview-area |
249 | // Fill gap between left selection/image border and left border of the preview-area |
228 | for (x = 0; x < filterPiece->left - pb->filterRect.left; ++x) { |
250 | for (x = 0; x < (double)filterPiece.left - (double)filterRect.left; ++x) { |
229 | #ifdef PROCESS_SCALED_GAP_DEBUG |
251 | #ifdef PROCESS_SCALED_GAP_DEBUG |
230 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 2a: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
252 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 2a: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
231 | #endif |
253 | #endif |
232 | 254 | ||
233 | var['x'] = (value_type)x; |
255 | var['x'] = (value_type)x; |
234 | evalpixel(NULL,inrow + (long)(x)*nplanes); |
256 | evalpixel(NULL,inrow + (long)(x)*nplanes); |
235 | } |
257 | } |
236 | } |
258 | } |
237 | 259 | ||
238 | // i indexes scaled output columns |
260 | // i indexes scaled output columns |
239 | for( outp = outrow, i = outPiece->left, x = filterPiece->left - pb->filterRect.left ; |
261 | for( outp = outrow, i = outPiece.left, x = (double)filterPiece.left - (double)filterRect.left ; |
240 | i < outPiece->right ; ++i, outp += nplanes, x += zoom ) |
262 | i < outPiece.right ; ++i, outp += nplanes, x += zoom ) |
241 | { |
263 | { |
242 | #ifdef PROCESS_SCALED_GAP_DEBUG |
264 | #ifdef PROCESS_SCALED_GAP_DEBUG |
243 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 2b: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
265 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 2b: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
244 | #endif |
266 | #endif |
245 | 267 | ||
Line 261... | Line 283... | ||
261 | } |
283 | } |
262 | 284 | ||
263 | if (state_changing_funcs_used) { |
285 | if (state_changing_funcs_used) { |
264 | // Fill gap between right border of preview-area and right border of selection/image border |
286 | // Fill gap between right border of preview-area and right border of selection/image border |
265 | 287 | ||
266 | for (x = var['x']+1; x < pb->filterRect.right - pb->filterRect.left; ++x) { |
288 | for (x = (double)var['x']+1; x < (double)filterRect.right - (double)filterRect.left; ++x) { |
267 | #ifdef PROCESS_SCALED_GAP_DEBUG |
289 | #ifdef PROCESS_SCALED_GAP_DEBUG |
268 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 2d: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
290 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 2d: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
269 | #endif |
291 | #endif |
270 | 292 | ||
271 | var['x'] = (value_type)x; |
293 | var['x'] = (value_type)x; |
Line 276... | Line 298... | ||
276 | if (var['x'] != var['X']-1) { sprintf(s, "X not at right border #2: x=%d, X=%d\n", var['x'], var['X']); simplealert(s);} |
298 | if (var['x'] != var['X']-1) { sprintf(s, "X not at right border #2: x=%d, X=%d\n", var['x'], var['X']); simplealert(s);} |
277 | #endif |
299 | #endif |
278 | 300 | ||
279 | // Fill gap between each Y-preview-pixel (discarded pixels due to zoom level), |
301 | // Fill gap between each Y-preview-pixel (discarded pixels due to zoom level), |
280 | // but not for the very last line, since we are then done drawing our preview picture |
302 | // but not for the very last line, since we are then done drawing our preview picture |
281 | for (k = y+1; floor(k) < floor(y + zoom) && (j < outPiece->bottom-1); ++k) { |
303 | for (k = y+1; floor(k) < floor(y + zoom) && (j < outPiece.bottom-1); ++k) { |
282 | #ifdef PROCESS_SCALED_GAP_DEBUG |
304 | #ifdef PROCESS_SCALED_GAP_DEBUG |
283 | if (state_changing_funcs_used && last_good_y != (int)floor(k-1)) { sprintf(s, "Non calculated Y gap, type 3a: %f (y=%f), last good %d, zoom %f\n", k, y, last_good_y, zoom); simplealert(s); } last_good_y = (int)floor(k); |
305 | if (state_changing_funcs_used && last_good_y != (int)floor(k-1)) { sprintf(s, "Non calculated Y gap, type 3a: %f (y=%f), last good %d, zoom %f\n", k, y, last_good_y, zoom); simplealert(s); } last_good_y = (int)floor(k); |
284 | #endif |
306 | #endif |
285 | 307 | ||
286 | var['y'] = (value_type)k; |
308 | var['y'] = (value_type)k; |
Line 289... | Line 311... | ||
289 | 311 | ||
290 | #ifdef PROCESS_SCALED_GAP_DEBUG |
312 | #ifdef PROCESS_SCALED_GAP_DEBUG |
291 | last_good_x = -1; |
313 | last_good_x = -1; |
292 | #endif |
314 | #endif |
293 | 315 | ||
294 | for (x = 0; x < pb->filterRect.right - pb->filterRect.left; ++x) { |
316 | for (x = 0; x < (double)filterRect.right - (double)filterRect.left; ++x) { |
295 | #ifdef PROCESS_SCALED_GAP_DEBUG |
317 | #ifdef PROCESS_SCALED_GAP_DEBUG |
296 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 3b: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
318 | if (state_changing_funcs_used && last_good_x != (int)floor(x-1)) { sprintf(s, "Non calculated X gap, type 3b: %f, last good %d, zoom %f\n", x, last_good_x, zoom); simplealert(s); } last_good_x = (int)floor(x); |
297 | #endif |
319 | #endif |
298 | 320 | ||
299 | var['x'] = (value_type)x; |
321 | var['x'] = (value_type)x; |
Line 310... | Line 332... | ||
310 | if((t = TICKCOUNT()) > ticks){ |
332 | if((t = TICKCOUNT()) > ticks){ |
311 | ticks = t + TICKS_SEC/4; |
333 | ticks = t + TICKS_SEC/4; |
312 | if(pb->abortProc()) |
334 | if(pb->abortProc()) |
313 | return userCanceledErr; |
335 | return userCanceledErr; |
314 | else |
336 | else |
315 | pb->progressProc((int)y - pb->filterRect.top,pb->filterRect.bottom - pb->filterRect.top); |
337 | pb->progressProc((int)y - filterRect.top,filterRect.bottom - filterRect.top); |
316 | } |
338 | } |
317 | } |
339 | } |
318 | #ifdef MAC_ENV |
340 | #ifdef MAC_ENV |
319 | else{ |
341 | else{ |
320 | /* to stop delays during typing of expressions, |
342 | /* to stop delays during typing of expressions, |
Line 330... | Line 352... | ||
330 | // of preview area and the bottom border of the selection/filter, because there are no |
352 | // of preview area and the bottom border of the selection/filter, because there are no |
331 | // preview output pixels left that could be affected by these gap evaluations. |
353 | // preview output pixels left that could be affected by these gap evaluations. |
332 | 354 | ||
333 | return noErr; |
355 | return noErr; |
334 | } |
356 | } |
- | 357 | ||
- | 358 | OSErr process_scaled_olddoc(FilterRecordPtr pb, Boolean progress, |
|
- | 359 | Rect filterPiece, Rect outPiece, |
|
- | 360 | void* outData, long outRowBytes, double zoom) { |
|
- | 361 | ||
- | 362 | VRect filterPiece32; |
|
- | 363 | VRect outPiece32; |
|
- | 364 | ||
- | 365 | filterPiece32.bottom = filterPiece.bottom; |
|
- | 366 | filterPiece32.left = filterPiece.left; |
|
- | 367 | filterPiece32.right = filterPiece.right; |
|
- | 368 | filterPiece32.top = filterPiece.top; |
|
- | 369 | ||
- | 370 | outPiece32.bottom = outPiece.bottom; |
|
- | 371 | outPiece32.left = outPiece.left; |
|
- | 372 | outPiece32.right = outPiece.right; |
|
- | 373 | outPiece32.top = outPiece.top; |
|
- | 374 | ||
- | 375 | return process_scaled_bigdoc(pb, progress, filterPiece32, outPiece32, outData, outRowBytes, zoom); |
|
- | 376 | } |