Subversion Repositories filter_foundry

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. //-------------------------------------------------------------------------------
  2. //
  3. //ÊÊÊ File:
  4. //ÊÊÊÊÊÊÊ prah.c
  5. //
  6.  
  7.  
  8. #include "PIDefines.h"
  9.  
  10. #ifdef __PIMWCWMacPPC__
  11. ÊÊÊ #include "prah-PPC.ch"
  12. #elif defined(__PIMWCWMac68K__)
  13. ÊÊÊ #include "prah-68k.ch"
  14. ÊÊÊ // We're using Metrowerks and they have an A4 library, so set that up:
  15. ÊÊÊ #include <SetupA4.h>
  16. ÊÊÊ #include <A4Stuff.h>
  17. ÊÊÊ
  18. ÊÊÊ #define UseA4 // We've now defined this for quick checks later.
  19. #else
  20. ÊÊÊ #include "prah.h"
  21. #endif
  22.  
  23. #include <math.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26.  
  27. #include <math.h>
  28.  
  29.  
  30. // Peker til tabellen
  31. //prcomplex *sincos_tab;
  32. //-------------------------------------------------------------------------------
  33. //ÊÊÊ Prototypes.
  34. //-------------------------------------------------------------------------------
  35.  
  36. // Everything comes in and out of ENTRYPOINT. It must be first routine in source:
  37. MACPASCAL void ENTRYPOINT (const short selector,
  38. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ FilterRecord *filterParamBlock,
  39. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ long *data,
  40. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ short *result);
  41. void InitGlobals (Ptr globalPtr); ÊÊÊÊÊÊÊÊÊÊÊ // Initialize globals.
  42. void ValidateParameters (GPtr globals);ÊÊÊÊÊÊÊ // Validates (inits) parameters.
  43.  
  44. void DoStart (GPtr globals); ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ // Main routine.
  45. void DoParameters (GPtr globals);
  46. void DoPrepare (GPtr globals);
  47. void DoContinue (GPtr globals);
  48. void DoFinish (GPtr globals);
  49.  
  50. void StartWithAdvanceState (GPtr globals);
  51.  
  52. void prah (GPtr globals, const Boolean doProgress);
  53.  
  54. void CalcProxyScaleFactor (Rect proxyScaleRect, Rect *proxyRect, short *scaleFactor);
  55. boolean ParametersTest(GPtr globals);
  56.  
  57. void ZoomInRect (GPtr globals, Boolean mask);
  58. void ZoomOutRect (GPtr globals, Boolean mask);
  59.  
  60. void StartNoAdvanceState (GPtr globals);
  61. void DoInitialRect (GPtr globals);
  62. Boolean DoNextRect (GPtr globals);
  63. //void Ret(GPtr globals);
  64.  
  65. void BuildProxy (GPtr globals);
  66. void scaleRect(Rect *l, short n, short d);
  67. void shrinkRect(Rect *l, short x, short y);
  68. void copyRect(Rect *l, const Rect *r);
  69. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  70. //-------------------------------------------------------------------------------
  71. //ÊÊÊ Globals -- Define global variables for plug-in scope.
  72. //-------------------------------------------------------------------------------
  73.  
  74. // Windows global for plug-in (considered a Dynamically Linked Library).
  75. // Leave NULL for Macintosh; many cross-platform library utilities require
  76. // something passed in for hDllInstance:
  77. Handle hDllInstance = NULL;
  78.  
  79. //-------------------------------------------------------------------------------
  80. //ÊÊÊ ENTRYPOINT Export -- Export our entrypoint
  81. //
  82. //ÊÊÊ Have to export our info for PPCGlue stub which needs a descriptor built
  83. //ÊÊÊ to be called from within a 68k code fragment.
  84. //-------------------------------------------------------------------------------
  85.  
  86. #ifdef __PIMacPPC__ ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ // For "fat" PowerMac plug-ins
  87.  
  88. ÊÊÊ enum
  89. ÊÊÊ {
  90. ÊÊÊÊÊÊÊ uppEntryProcInfo = kPascalStackBased
  91. ÊÊÊÊÊÊÊÊÊÊÊ | RESULT_SIZE(0)
  92. ÊÊÊÊÊÊÊÊÊÊÊ | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  93. ÊÊÊÊÊÊÊÊÊÊÊ | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FilterRecord *)))
  94. ÊÊÊÊÊÊÊÊÊÊÊ | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *)))
  95. ÊÊÊÊÊÊÊÊÊÊÊ | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short *)))
  96. ÊÊÊ };
  97.  
  98. ÊÊÊ #if PRAGMA_EXPORT_SUPPORTED
  99. ÊÊÊÊÊÊÊ #pragma export on
  100. ÊÊÊ #endif
  101.  
  102. ÊÊÊ RoutineDescriptor main_PPC = BUILD_ROUTINE_DESCRIPTOR(uppEntryProcInfo, main);
  103.  
  104. ÊÊÊ #if PRAGMA_EXPORT_SUPPORTED
  105. ÊÊÊÊÊÊÊ #pragma export reset
  106. ÊÊÊ #endif
  107.  
  108. #endif
  109.  
  110. //-------------------------------------------------------------------------------
  111. //
  112. //ÊÊÊ ENTRYPOINT / main
  113. //
  114. //ÊÊÊ All calls to the plug-in module come through this routine.
  115. //ÊÊÊ It must be placed first in the resource. To achieve this,
  116. //ÊÊÊ most development systems require this be the first routine
  117. //ÊÊÊ in the source.
  118. //
  119. //ÊÊÊ The entrypoint will be "pascal void" for Macintosh,
  120. //ÊÊÊ "void" for Windows.
  121. //
  122. //ÊÊÊ Inputs:
  123. //ÊÊÊÊÊÊÊ const short selector ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ Host provides selector indicating
  124. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ what command to do.
  125. //
  126. //ÊÊÊÊÊÊÊ FilterRecord *filterParamBlock ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ Host provides pointer to parameter
  127. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ block containing pertinent data
  128. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ and callbacks from the host.
  129. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ See PIFilter.h.
  130. //
  131. //ÊÊÊ Outputs:
  132. //ÊÊÊÊÊÊÊ FilterRecord *filterParamBlock ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ Host provides pointer to parameter
  133. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ block containing pertinent data
  134. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ and callbacks from the host.
  135. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ See PIFilter.h.
  136. //
  137. //ÊÊÊÊÊÊÊ long *data ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ Use this to store a handle to our
  138. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ global parameters structure, which
  139. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ is maintained by the host between
  140. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ calls to the plug-in.
  141. //
  142. //ÊÊÊÊÊÊÊ short *result ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ Return error result or noErr. Some
  143. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ errors are handled by the host, some
  144. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ are silent, and some you must handle.
  145. // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ See PIGeneral.h.
  146. //
  147. //-------------------------------------------------------------------------------
  148.  
  149. MACPASCAL void ENTRYPOINT (const short selector,
  150. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ FilterRecord *filterParamBlock,
  151. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ long *data,
  152. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ short *result)
  153. {
  154. ÊÊÊ //---------------------------------------------------------------------------
  155. ÊÊÊ //ÊÊÊ (1) Enter code resource if Mac 68k.
  156. ÊÊÊ //---------------------------------------------------------------------------
  157. ÊÊÊ
  158. ÊÊÊ #ifdef UseA4 ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ // Are we in 68k Mac MW?
  159. ÊÊÊÊÊÊÊ EnterCodeResource();ÊÊÊÊ // A4-globals
  160. ÊÊÊ #endif
  161. ÊÊÊ
  162. ÊÊÊ //---------------------------------------------------------------------------
  163. ÊÊÊ //ÊÊÊ (2) Check for about box request.
  164. ÊÊÊ //
  165. ÊÊÊ //ÊÊÊÊ The about box is a special request; the parameter block is not filled
  166. ÊÊÊ //ÊÊÊÊ out, none of the callbacks or standard data is available. Instead,
  167. ÊÊÊ //ÊÊÊÊ the parameter block points to an AboutRecord, which is used
  168. ÊÊÊ //ÊÊÊÊ on Windows.
  169. ÊÊÊ //---------------------------------------------------------------------------
  170.  
  171. ÊÊÊ if (selector == filterSelectorAbout)
  172. ÊÊÊ {
  173. ÊÊÊÊÊÊÊ DoAbout((AboutRecordPtr)filterParamBlock);
  174. ÊÊÊ }
  175. ÊÊÊ else
  176. ÊÊÊ { // do the rest of the process as normal:
  177.  
  178. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  179. ÊÊÊÊÊÊÊ //ÊÊÊ (3) Initialize function and global pointers.
  180. ÊÊÊÊÊÊÊ //
  181. ÊÊÊÊÊÊÊ //ÊÊÊÊ Initialize function pointer routine dispatcher. We use this to jump
  182. ÊÊÊÊÊÊÊ //ÊÊÊÊ to the different routines, instead of a long obnoxious switch
  183. ÊÊÊÊÊÊÊ //ÊÊÊÊ statement. All routines are expected to have the same prototype
  184. ÊÊÊÊÊÊÊ //ÊÊÊÊ of "void RoutineName (globals)". Returns any errors in gResult.
  185. ÊÊÊÊÊÊÊ //
  186. ÊÊÊÊÊÊÊ //ÊÊÊÊ WARNING: These better be in the order of the selector AND there
  187. ÊÊÊÊÊÊÊ //ÊÊÊÊ better be a routine for every selector call.
  188. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  189. ÊÊÊÊÊÊÊ
  190. ÊÊÊÊÊÊÊ static const FProc routineForSelector [] =
  191. ÊÊÊÊÊÊÊ {
  192. ÊÊÊÊÊÊÊÊÊÊÊ /* filterSelectorAbout ÊÊÊÊÊÊÊÊÊÊÊÊ DoAbout, */
  193. ÊÊÊÊÊÊÊÊÊÊÊ /* filterSelectorParameters */ÊÊÊ DoParameters,
  194. ÊÊÊÊÊÊÊÊÊÊÊ /* filterSelectorPrepare */ÊÊÊÊÊÊÊ DoPrepare,
  195. ÊÊÊÊÊÊÊÊÊÊÊ /* filterSelectorStart */ÊÊÊÊÊÊÊ DoStart,
  196. ÊÊÊÊÊÊÊÊÊÊÊ /* filterSelectorContinue */ÊÊÊ DoContinue,
  197. ÊÊÊÊÊÊÊÊÊÊÊ /* filterSelectorFinish */ÊÊÊÊÊÊÊ DoFinish
  198. ÊÊÊÊÊÊÊ };
  199. ÊÊÊÊÊÊÊ
  200. ÊÊÊÊÊÊÊ Ptr globalPtr = NULL; ÊÊÊÊÊÊÊ // Pointer for global structure
  201. ÊÊÊÊÊÊÊ GPtr globals = NULL; ÊÊÊÊÊÊÊÊ // actual globals
  202.  
  203. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  204. ÊÊÊÊÊÊÊ //ÊÊÊ (4) Allocate and initalize globals.
  205. ÊÊÊÊÊÊÊ //
  206. ÊÊÊÊÊÊÊ //ÊÊÊÊ AllocateGlobals requires the pointer to result, the pointer to the
  207. ÊÊÊÊÊÊÊ //ÊÊÊÊ parameter block, a pointer to the handle procs, the size of our local
  208. ÊÊÊÊÊÊÊ //ÊÊÊÊ "Globals" structure, a pointer to the long *data, a Function
  209. ÊÊÊÊÊÊÊ //ÊÊÊÊ Proc (FProc) to the InitGlobals routine. It automatically sets-up,
  210. ÊÊÊÊÊÊÊ //ÊÊÊÊ initializes the globals (if necessary), results result to 0, and
  211. ÊÊÊÊÊÊÊ //ÊÊÊÊ returns with a valid pointer to the locked globals handle or NULL.
  212. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  213. ÊÊÊÊÊÊÊ
  214. ÊÊÊÊÊÊÊ globalPtr = AllocateGlobals ((uint32)result,
  215. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ (uint32)filterParamBlock,
  216. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ filterParamBlock->handleProcs,
  217. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ sizeof(Globals),
  218. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ data,
  219. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ InitGlobals);
  220. ÊÊÊÊÊÊÊ
  221. ÊÊÊÊÊÊÊ if (globalPtr == NULL)
  222. ÊÊÊÊÊÊÊ { // Something bad happened if we couldn't allocate our pointer.
  223. ÊÊÊÊÊÊÊ // Fortunately, everything's already been cleaned up,
  224. ÊÊÊÊÊÊÊ // so all we have to do is report an error.
  225. ÊÊÊÊÊÊÊ
  226. ÊÊÊÊÊÊÊ *result = memFullErr;
  227. ÊÊÊÊÊÊÊ return;
  228. ÊÊÊÊÊÊÊ }
  229. ÊÊÊÊÊÊÊ
  230. ÊÊÊÊÊÊÊ // Get our "globals" variable assigned as a Global Pointer struct with the
  231. ÊÊÊÊÊÊÊ // data we've returned:
  232. ÊÊÊÊÊÊÊ globals = (GPtr)globalPtr;
  233.  
  234. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  235. ÊÊÊÊÊÊÊ //ÊÊÊ (5) Dispatch selector.
  236. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  237.  
  238. ÊÊÊÊÊÊÊ if (selector > filterSelectorAbout && selector <= filterSelectorFinish)
  239. ÊÊÊÊÊÊÊÊÊÊÊ (routineForSelector[selector-1])(globals); // dispatch using jump table
  240. ÊÊÊÊÊÊÊ else
  241. ÊÊÊÊÊÊÊÊÊÊÊ gResult = filterBadParameters;
  242. ÊÊÊÊÊÊÊÊÊÊÊ
  243. ÊÊÊÊÊÊÊ //-----------------------------------------------------------------------
  244. ÊÊÊÊÊÊÊ //ÊÊÊ (6) Unlock data, and exit resource.
  245. ÊÊÊÊÊÊÊ //
  246. ÊÊÊÊÊÊÊ //ÊÊÊ Result is automatically returned in *result, which is
  247. ÊÊÊÊÊÊÊ //ÊÊÊ pointed to by gResult.
  248. ÊÊÊÊÊÊÊ //----------------------------------------------------------------------- ÊÊÊ
  249. ÊÊÊÊÊÊÊ
  250. ÊÊÊÊÊÊÊ // unlock handle pointing to parameter block and data so it can move
  251. ÊÊÊÊÊÊÊ // if memory gets shuffled:
  252. ÊÊÊÊÊÊÊ if ((Handle)*data != NULL)
  253. ÊÊÊÊÊÊÊÊÊÊÊ PIUnlockHandle((Handle)*data);
  254. ÊÊÊ
  255. ÊÊÊ } // about selector specialÊÊÊÊÊÊÊ
  256. ÊÊÊ
  257. ÊÊÊ #ifdef UseA4 ÊÊÊÊÊÊÊÊÊÊÊ // Are we in 68k Mac MW?
  258. ÊÊÊÊÊÊÊ ExitCodeResource(); // A4-globals
  259. ÊÊÊ #endif
  260. ÊÊÊ
  261. } // end ENTRYPOINT
  262.  
  263. //-------------------------------------------------------------------------------
  264. //
  265. //ÊÊÊ InitGlobals
  266. //ÊÊÊ
  267. //ÊÊÊ Initalize any global values here. Called only once when global
  268. //ÊÊÊ space is reserved for the first time.
  269. //
  270. //ÊÊÊ Inputs:
  271. //ÊÊÊÊÊÊÊ Ptr globalPtr ÊÊÊÊÊÊÊ Standard pointer to a global structure.
  272. //
  273. //ÊÊÊ Outputs:
  274. //ÊÊÊÊÊÊÊ Initializes any global values with their defaults.
  275. //
  276. //-------------------------------------------------------------------------------
  277.  
  278.  
  279.  
  280. void InitGlobals (Ptr globalPtr)
  281. {ÊÊÊ
  282. ÊÊÊ // create "globals" as a our struct global pointer so that any
  283. ÊÊÊ // macros work:
  284. ÊÊÊ GPtr globals = (GPtr)globalPtr;
  285. ÊÊÊ
  286. ÊÊÊ // Initialize global variables:
  287. ÊÊÊ ValidateParameters (globals);
  288. ÊÊÊ
  289. } // end InitGlobals
  290.  
  291. //-------------------------------------------------------------------------------
  292. //
  293. //ÊÊÊ ValidateParameters
  294. //
  295. //ÊÊÊ Initialize parameters to default values.
  296. //
  297. //ÊÊÊ Inputs:
  298. //ÊÊÊÊÊÊÊ GPtr globals ÊÊÊÊÊÊÊ Pointer to global structure.
  299. //
  300. //-------------------------------------------------------------------------------
  301.  
  302. void ValidateParameters (GPtr globals)
  303. {
  304. ÊÊÊ if (gStuff->parameters == NULL)
  305. ÊÊÊ { // We haven't created these yet.
  306.  
  307. ÊÊÊÊÊÊÊ gStuff->parameters = PINewHandle ((long) sizeof (TParameters));
  308.  
  309. ÊÊÊÊÊÊÊ if (gStuff->parameters != NULL)
  310. ÊÊÊÊÊÊÊ { // Got it. Fill out the fields. ÊÊÊ
  311. ÊÊÊÊÊÊÊÊÊÊÊ gKanal1=128;
  312. ÊÊÊÊÊÊÊÊÊÊÊ gKanal2=128;
  313. ÊÊÊÊÊÊÊÊÊÊÊ gKanal3=128;
  314. ÊÊÊÊÊÊÊÊÊÊÊ gKanal4=128; ÊÊÊÊÊÊÊ
  315. ÊÊÊÊÊÊÊÊÊÊÊ
  316. ÊÊÊÊÊÊÊÊÊÊÊ gUseAdvance = false;
  317. ÊÊÊÊÊÊÊÊÊÊÊ gZoomFactor=6; ÊÊÊÊÊÊÊ
  318. ÊÊÊÊÊÊÊÊÊÊÊ gHostIsPremiereWin = IsWindows(HostIsPremiere());
  319. ÊÊÊÊÊÊÊ }
  320. ÊÊÊÊÊÊÊ else
  321. ÊÊÊÊÊÊÊ { // Oops. Couldn't allocate memory.
  322. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  323. ÊÊÊÊÊÊÊÊÊÊÊ gResult = memFullErr;
  324. ÊÊÊÊÊÊÊÊÊÊÊ return;
  325. ÊÊÊÊÊÊÊ }
  326. ÊÊÊ } // parameters
  327. ÊÊÊ
  328. } // end ValidateParameters
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335. /*****************************************************************************/
  336. /* Inicializace vstupn’ch parametr? filtru - neprob?hne p?i vol‡n’ "Posledn’ Filtr"*/
  337.  
  338. void DoParameters (GPtr globals)
  339. {ÊÊÊ
  340. ÊÊÊ ValidateParameters (globals);
  341. ÊÊÊ if (gStuff->parameters != NULL)
  342. ÊÊÊ {
  343. ÊÊÊ }
  344. ÊÊÊ gQueryForParameters = TRUE;
  345. }
  346.  
  347. /*****************************************************************************/
  348. /* V?po?et pot?ebnŽ pam?ti pro funkci filtru */
  349.  
  350. void DoPrepare (GPtr globals)
  351. {
  352. ÊÊÊ shortÊÊÊÊ rowWidth = 0;
  353. ÊÊÊ shortÊÊÊÊ total = 0;
  354. ÊÊÊ longÊÊÊ oneRow = 0;
  355. ÊÊÊ longÊÊÊ inOutRow = 0;
  356. ÊÊÊ longÊÊÊ inOutAndMask = 0;
  357. ÊÊÊ
  358. ÊÊÊ gStuff->bufferSpace = 0;ÊÊÊ
  359. ÊÊÊ ValidateParameters (globals);
  360. ÊÊÊ total = gStuff->imageSize.v;
  361. ÊÊÊ rowWidth = gStuff->imageSize.h;ÊÊÊ
  362. ÊÊÊ oneRow = rowWidth * (gStuff->planes);
  363. ÊÊÊ inOutRow = oneRow * 2;
  364. ÊÊÊ inOutAndMask = inOutRow + rowWidth;
  365. ÊÊÊ while (((inOutAndMask * gRowSkip) < (gStuff->maxSpace-gStuff->bufferSpace)) && (gRowSkip < total)) gRowSkip++;
  366. ÊÊÊ gStuff->maxSpace = gRowSkip * inOutAndMask + gStuff->bufferSpace;
  367. ÊÊÊ
  368. }
  369.  
  370. /*****************************************************************************/
  371. /* Zobrazen’ UI a za?‡tek filtrace */
  372.  
  373. void DoStart (GPtr globals)
  374. {ÊÊÊ
  375.  
  376. ÊÊÊ RectÊÊÊ imageRect;
  377. ÊÊÊÊÊÊÊ return;
  378. ÊÊÊ ValidateParameters (globals); // Pokud nejsou inicializov‡ny parametry filtru, tak je inicializuje
  379. ÊÊÊ // lze pou?’t Advance ?
  380. ÊÊÊ gUseAdvance = AdvanceStateAvailable () &&
  381. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ DisplayPixelsAvailable () &&
  382. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ !gHostIsPremiereWin;
  383. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ // Adobe Premiere for Windows doesn't do AdvanceState right
  384. ÊÊÊ ReadScriptParams (globals); ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ // P?e?te p?edchoz’ nastaven’ filtru
  385.  
  386. ÊÊÊ if (gQueryForParameters)
  387. ÊÊÊ {
  388. ÊÊÊÊÊÊÊ DoUI (globals); ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ // Zobraz’ UI
  389. ÊÊÊÊÊÊÊ gQueryForParameters = FALSE;
  390. ÊÊÊ }
  391. ÊÊÊ else
  392. ÊÊÊ {
  393. ÊÊÊÊÊÊÊ imageRect.top = 0;//pokud je filtr vyvol‡n bez UI - inicializace rozmeru I/O oblast’
  394. ÊÊÊÊÊÊÊ imageRect.left = 0;
  395. ÊÊÊÊÊÊÊ imageRect.bottom = gStuff->imageSize.v;
  396. ÊÊÊÊÊÊÊ imageRect.right = gStuff->imageSize.h;
  397. ÊÊÊÊÊÊÊ copyRect(&gStuff->filterRect, &imageRect);
  398. ÊÊÊÊÊÊÊ copyRect(&gStuff->inRect, &imageRect);ÊÊÊÊÊÊÊ
  399.  
  400. ÊÊÊÊÊÊÊ gStuff->inLoPlane = gStuff->outLoPlane = 0;
  401. ÊÊÊÊÊÊÊ gStuff->inHiPlane = gStuff->outHiPlane = gStuff->planes - 1;
  402. ÊÊÊÊÊÊÊ copyRect(&gStuff->maskRect, &gStuff->filterRect);
  403. ÊÊÊÊÊÊÊ gStuff->inputRate = long2fixed(1L);
  404. ÊÊÊÊÊÊÊ gStuff->maskRate = gStuff->inputRate;
  405. ÊÊÊÊÊÊÊ gStuff->inputPadding = plugInWantsEdgeReplication;
  406. ÊÊÊÊÊÊÊ gStuff->outputPadding = gStuff->inputPadding;
  407. ÊÊÊÊÊÊÊ gStuff->maskPadding = gStuff->inputPadding;
  408. ÊÊÊ
  409. ÊÊÊÊÊÊÊ gResult = AdvanceState ();
  410. ÊÊÊÊÊÊÊ DoZoomRect (globals,false);
  411. //ÊÊÊÊÊÊÊ Ret(globals);
  412. ÊÊÊÊÊÊÊ
  413. ÊÊÊ }
  414. ÊÊÊ if (gResult != noErr) return;
  415. ÊÊÊ
  416. ÊÊÊ if (gUseAdvance) StartWithAdvanceState(globals);
  417. }
  418. ÊÊÊ
  419. /*****************************************************************************/
  420. /* Pokra?ov‡n’ filtrace - pokud se filtruje po ?‡stech - not Advance */
  421.  
  422. void DoContinue (GPtr globals)
  423. {
  424. ÊÊÊ if (TestAbort () || gResult != noErr)
  425. ÊÊÊ {
  426. ÊÊÊÊÊÊÊ gResult = userCanceledErr;
  427. ÊÊÊÊÊÊÊ return;
  428. ÊÊÊ }
  429. ÊÊÊ if (!gUseAdvance)
  430. ÊÊÊ {
  431. ÊÊÊÊÊÊÊ Prah(globals,true);
  432. ÊÊÊÊÊÊÊ if (!DoNextRect (globals))
  433. ÊÊÊÊÊÊÊÊÊÊÊ {
  434. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ PISetRect (&gStuff->inRect, 0, 0, 0, 0);
  435. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ PISetRect (&gStuff->outRect, 0, 0, 0, 0);
  436. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ PISetRect (&gStuff->maskRect, 0, 0, 0, 0);
  437. ÊÊÊÊÊÊÊÊÊÊÊ }
  438. ÊÊÊ }
  439. ÊÊÊ else
  440. ÊÊÊ {
  441. ÊÊÊÊÊÊÊ PISetRect (&gStuff->inRect, 0, 0, 0, 0);
  442. ÊÊÊÊÊÊÊ PISetRect (&gStuff->outRect, 0, 0, 0, 0);
  443. ÊÊÊÊÊÊÊ PISetRect (&gStuff->maskRect, 0, 0, 0, 0);
  444. ÊÊÊ }
  445. }
  446.  
  447. /*****************************************************************************/
  448. /* òklid po filtru a z‡pis nastaven’ parametr? filtru */
  449.  
  450. void DoFinish (GPtr globals)
  451. {
  452. ÊÊÊ WriteScriptParams (globals);
  453. }
  454.  
  455. /*****************************************************************************/
  456. /* Filtrace celeho obrazu najednou */
  457.  
  458. void StartWithAdvanceState (GPtr globals)
  459. {
  460. ÊÊÊ int16 row;
  461. ÊÊÊ int32 total;
  462.  
  463. ÊÊÊ total = gStuff->filterRect.bottom - gStuff->filterRect.top;
  464. ÊÊÊ gStuff->inLoPlane = gStuff->outLoPlane = 0;
  465. ÊÊÊ gStuff->inHiPlane = gStuff->outHiPlane = gStuff->planes - 1;
  466. ÊÊÊ
  467. ÊÊÊ /* Pokud chceme pou?’t kan‡ly*/
  468. ÊÊÊ #if useAlpha
  469. ÊÊÊ if (!gStuff->isFloating)
  470. ÊÊÊ {
  471. ÊÊÊÊÊÊÊ gStuff->wantsAbsolute = true;
  472. ÊÊÊÊÊÊÊ
  473. ÊÊÊÊÊÊÊ if (gStuff->inLayerPlanes !=0 && gStuff->inTransparencyMask != 0)
  474. ÊÊÊÊÊÊÊÊÊÊÊ gStuff->inHiPlane = gStuff->absLayerPlanes - 1 +
  475. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absTransparencyMask +
  476. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absLayerMasks +
  477. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absInvertedLayerMasks +
  478. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absNonLayerPlanes;
  479. ÊÊÊÊÊÊÊ
  480. ÊÊÊÊÊÊÊ if (gStuff->outLayerPlanes !=0 && gStuff->outTransparencyMask !=0)
  481. ÊÊÊÊÊÊÊÊÊÊÊ gStuff->outHiPlane = gStuff->outLayerPlanes - 1 +
  482. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outTransparencyMask +
  483. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outLayerMasks +
  484. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outInvertedLayerMasks +
  485. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outNonLayerPlanes;
  486. ÊÊÊ }
  487. ÊÊÊ #endif
  488. ÊÊÊ gStuff->inRect.left = gStuff->outRect.left = gStuff->maskRect.left = gStuff->filterRect.left = 0;
  489. ÊÊÊ gStuff->inRect.right = gStuff->outRect.right = gStuff->maskRect.right = gStuff->filterRect.right = gStuff->imageSize.h;
  490. ÊÊÊ gStuff->inputRate = long2fixed (1L);
  491. ÊÊÊ gStuff->maskRate = long2fixed (1L);
  492. ÊÊÊ for (row = 0; row < gStuff->imageSize.v; row += gRowSkip)
  493. ÊÊÊ {
  494. ÊÊÊÊÊÊÊ if (TestAbort () || gResult != noErr)
  495. ÊÊÊÊÊÊÊ {
  496. ÊÊÊÊÊÊÊÊÊÊÊ gResult = userCanceledErr;
  497. ÊÊÊÊÊÊÊÊÊÊÊ goto done;
  498. ÊÊÊÊÊÊÊ }
  499. ÊÊÊÊÊÊÊ gStuff->inRect.top = gStuff->outRect.top = gStuff->maskRect.top = gStuff->filterRect.top=row;
  500. ÊÊÊÊÊÊÊ gStuff->inRect.bottom = gStuff->outRect.bottom = gStuff->maskRect.bottom = gStuff->filterRect.bottom=row + gRowSkip;
  501. ÊÊÊÊÊÊÊ gResult = AdvanceState ();ÊÊÊ
  502. ÊÊÊÊÊÊÊ if (gResult != noErr)
  503. ÊÊÊÊÊÊÊÊÊÊÊ goto done; ÊÊÊÊÊÊÊ
  504. ÊÊÊÊÊÊÊ Prah (globals, true);
  505. ÊÊÊÊÊÊÊ }
  506. done:
  507. ÊÊÊ PISetRect (&gStuff->inRect, 0, 0, 0, 0);
  508. ÊÊÊ PISetRect (&gStuff->outRect, 0, 0, 0, 0);
  509. ÊÊÊ PISetRect (&gStuff->maskRect, 0, 0, 0, 0);
  510. }
  511.  
  512.  
  513. /******************************************************/
  514. /* proveden’ filtrace ÊÊÊÊÊÊÊÊÊÊÊ */
  515.  
  516.  
  517.  
  518. void Prah(GPtr globals, Boolean doProgress )
  519. {
  520. ÊÊÊ short i, j;
  521. ÊÊÊ int plane;
  522. ÊÊÊ int prah[4];
  523.  
  524. ÊÊÊ const short total = gStuff->filterRect.bottom - gStuff->filterRect.top;ÊÊÊ //celkov? pocet v?stupn’ho ?‡dk?
  525. ÊÊÊ const short outColumns= gStuff->outRect.right - gStuff->outRect.left; //pocet sloupc? v?stupn’ho obr‡zku
  526. ÊÊÊ const short outRows = gStuff->outRect.bottom - gStuff->outRect.top;ÊÊÊ // pocet ?‡dk? v?stupn’ho obr‡zku
  527. ÊÊÊ const short outPlanes = gStuff->outHiPlane - gStuff->outLoPlane + 1; //pocet kan‡l? v?stupn’ho obr‡zku
  528. ÊÊÊ const short inColumns = gStuff->imageSize.h; ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ //pocet sloupc? vstupniho obr‡zku
  529. ÊÊÊ const short inRows = gStuff->imageSize.v; ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ //pocet ?‡dk? vstupniho obr‡zku
  530. ÊÊÊ const short inPlanes = gStuff->inHiPlane - gStuff->inLoPlane + 1; ÊÊÊÊÊÊÊ //pocet kan‡l? vstupniho obr‡zku
  531. ÊÊÊ
  532. unsigned8 *srcPtr = (unsigned8 *) gStuff->inData;ÊÊÊ //ukazatel na vstupn’ obr‡zek
  533. ÊÊÊ unsigned8 *dstPtr = (unsigned8 *) gStuff->outData; ÊÊÊ //ukazatel na v?stupn’ obr‡zek
  534. ÊÊÊ unsigned8 *mskPtr = (unsigned8 *) gStuff->maskData; ÊÊÊ //ukazatel na masku vstupn’ho obr‡zku
  535. ÊÊÊ Boolean maskPixel = false;
  536.  
  537. ÊÊÊ
  538. ÊÊ prah[0]=gKanal1;//nastaven’ jednotliv?ch prah?
  539. ÊÊÊ prah[1]=gKanal2;
  540. ÊÊÊ prah[2]=gKanal3;
  541. ÊÊÊ prah[3]=gKanal4;
  542. ÊÊÊ for (i=0; i < inRows; i++)
  543. ÊÊÊ {
  544. ÊÊÊÊÊÊÊ srcPtr = (unsigned8 *) gStuff->inData + (i * inColumns * inPlanes);//nastav na prvn’ pixel v ?‡dku i
  545. ÊÊÊÊÊÊÊ dstPtr = (unsigned8 *) gStuff->outData + (i * inColumns * inPlanes);//nastav na prvn’ pixel v ?‡dku i
  546. ÊÊÊÊÊÊÊ mskPtr = (unsigned8 *) gStuff->maskData + (i * inColumns);ÊÊÊ //nastav na prvn’ pixel v ?‡dkuÊÊÊ i
  547. ÊÊÊÊÊÊÊÊÊÊÊ
  548. ÊÊÊÊÊÊÊ if (doProgress) UpdateProgress ((long) (gStuff->outRect.top + i) - gStuff->filterRect.top,(long) total);
  549. ÊÊÊÊÊÊÊ for(j=0;j<inColumns;j++)
  550. ÊÊÊÊÊÊÊ {
  551. ÊÊÊÊÊÊÊÊÊÊÊ
  552. ÊÊÊÊÊÊÊÊÊÊÊ maskPixel = (!mskPtr [0]); //na?ten’ masky
  553. ÊÊÊÊÊÊÊÊÊÊÊ if (!maskPixel) ÊÊÊ //pokud nen’ maska uprav
  554. ÊÊÊÊÊÊÊÊÊÊÊ {
  555. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ for (plane = 0; plane < inPlanes; plane++)
  556. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ {
  557. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ if(srcPtr[plane]>prah[plane]) srcPtr[plane]=255;
  558. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ else srcPtr[plane]=0;
  559. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ }
  560. ÊÊÊÊÊÊÊÊÊÊÊ }
  561. ÊÊÊÊÊÊÊÊÊÊÊ else //pokud je tak neupravuj
  562. ÊÊÊÊÊÊÊÊÊÊÊ {
  563. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ for (plane = 0; plane < inPlanes; plane++) dstPtr [plane] = srcPtr [plane]; ÊÊÊÊÊÊÊ
  564. ÊÊÊÊÊÊÊÊÊÊÊ } ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  565. ÊÊÊÊÊÊÊÊÊÊÊ srcPtr += inPlanes;//nastav na dal?’ pixel v ?‡dku i
  566. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr += inPlanes;//nastav na dal?’ pixel v ?‡dku i
  567. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr++; //nastav na dal?’ pixel v ?‡dku i
  568. ÊÊÊÊÊÊÊ } ÊÊÊÊÊÊÊÊÊÊÊ
  569. ÊÊÊ }
  570. }
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577. /*****************************************************************************/
  578. /* V?po?et a œpravy rozm?r? obr‡zku pro pot?eby UI */
  579.  
  580. void CalcGlobalProxies (GPtr globals)
  581. {
  582. ÊÊÊ RectÊÊÊ imageRect,imageRect1;
  583. ÊÊÊ int16ÊÊÊ selCenterH, selCenterV;
  584. ÊÊÊ int16ÊÊÊ selLength, selWidth;
  585. ÊÊÊ int16ÊÊÊ length, width;
  586. ÊÊÊ int16ÊÊÊ length2, width2;
  587. ÊÊÊ length = (gOrigProxyRect.bottom - gOrigProxyRect.top); // zobrazovan‡ v??ka
  588. ÊÊÊ length2 = length / 2;
  589. ÊÊÊ width = (gOrigProxyRect.right - gOrigProxyRect.left); // zobrazovan‡ ?’?ka
  590. ÊÊÊ width2 = width / 2;
  591. ÊÊÊ selLength = gStuff->imageSize.v; // Vybran‡ v??ka
  592. ÊÊÊ selWidth = gStuff->imageSize.h; // Vybran‡ ?’?ka
  593. ÊÊÊ //Vycentrov‡n’ preview
  594. ÊÊÊ selCenterV = (selLength / 2);
  595. ÊÊÊ selCenterH = (selWidth / 2);
  596. ÊÊÊ imageRect.top = selCenterV - (length2);
  597. ÊÊÊ imageRect.left = selCenterH - (width2);
  598. ÊÊÊ imageRect.bottom = imageRect.top+length;
  599. ÊÊÊ imageRect.right = imageRect.left+width;
  600. ÊÊÊ imageRect1.top = 0;
  601. ÊÊÊ imageRect1.left = 0;
  602. ÊÊÊ imageRect1.bottom = gStuff->imageSize.v;
  603. ÊÊÊ imageRect1.right = gStuff->imageSize.h;
  604. copyRect(&gProxyScaleRect, &imageRect);
  605. ÊÊÊ copyRect(&gStuff->inRect, &imageRect1);
  606. ÊÊÊ copyRect(&gStuff->outRect, &imageRect);
  607. }
  608.  
  609. void SetupFilterRecordForProxy (GPtr globals, Rect proxyScaleRect, short scaleFactor)
  610. {
  611. ÊÊÊ #ifdef __PIMWCW__
  612. ÊÊÊÊÊÊÊ #pragma unused (proxyScaleRect)
  613. ÊÊÊÊÊÊÊ #pragma unused (scaleFactor)
  614. ÊÊÊ #endif
  615. ÊÊÊ gStuff->inLoPlane = gStuff->outLoPlane = 0;
  616. ÊÊÊ gStuff->inHiPlane = gStuff->outHiPlane = gStuff->planes - 1;
  617. ÊÊÊ copyRect(&gStuff->maskRect, &gStuff->filterRect);
  618. ÊÊÊ gStuff->inputRate = long2fixed(1L);
  619. ÊÊÊ gStuff->maskRate = gStuff->inputRate;
  620. ÊÊÊ gStuff->inputPadding = plugInWantsEdgeReplication;
  621. ÊÊÊ gStuff->outputPadding = gStuff->inputPadding;
  622. ÊÊÊ gStuff->maskPadding = gStuff->inputPadding;
  623. ÊÊÊ gResult = AdvanceState ();
  624. }
  625. ÊÊÊ
  626. void CalcProxyScaleFactor (Rect proxyScaleRect, Rect *proxyRect, short *scaleFactor)
  627. {
  628. ÊÊÊ short filterHeight;
  629. ÊÊÊ short filterWidth;
  630. ÊÊÊ short itemHeight;
  631. ÊÊÊ short itemWidth;
  632.  
  633. ÊÊÊ Point fraction;
  634.  
  635. ÊÊÊ shrinkRect (proxyRect, kGutter, kGutter); ÊÊÊÊÊÊÊÊ // for the border
  636. ÊÊÊ filterHeight = (proxyScaleRect.bottom - proxyScaleRect.top);
  637. ÊÊÊ filterWidth = (proxyScaleRect.right - proxyScaleRect.left);
  638. ÊÊÊ itemHeight = (proxyRect->bottom - proxyRect->top);
  639. ÊÊÊ itemWidth = (proxyRect->right - proxyRect->left);
  640. ÊÊÊ if (itemHeight > filterHeight) itemHeight = filterHeight;
  641. ÊÊÊ if (itemWidth > filterWidth) itemWidth = filterWidth;
  642. ÊÊÊ fraction.h = ((filterWidth + itemWidth) / itemWidth)-1;
  643. ÊÊÊ fraction.v = ((filterHeight + itemHeight) / itemHeight)-1;
  644. ÊÊÊ if (fraction.h > fraction.v) *scaleFactor = fraction.h;
  645. ÊÊÊ else *scaleFactor = fraction.v;
  646. ÊÊÊ copyRect (proxyRect, &proxyScaleRect);ÊÊÊ
  647. ÊÊÊ scaleRect (proxyRect, 1, *scaleFactor);
  648. }
  649.  
  650.  
  651. /****************************************************************************/
  652. /* Hlavn’ rutina Zoomov‡n’ preview */
  653. void DoZoomRect (GPtr globals,Boolean mask)
  654. {ÊÊÊ
  655.  
  656. ÊÊÊ if (gResult == userCanceledErr) return;
  657. ÊÊÊÊÊÊÊ
  658. ÊÊÊ if (gRepFactor <= 1 && gRepFactor > 0)
  659. ÊÊÊÊÊÊÊ ZoomOutRect (globals, mask);
  660. ÊÊÊ else if (gRepFactor > 1)
  661. ÊÊÊÊÊÊÊ ZoomInRect (globals, mask); ÊÊÊÊÊÊÊ
  662. }
  663.  
  664. /*****************************************************************************/
  665. /* Zoom in. Zv?t?en’ gRepFactor >= 1 */
  666. /*****************************************************************************/
  667.  
  668. void ZoomInRect (GPtr globals, Boolean mask)
  669. {
  670. ÊÊÊ short offsetOutColumns, offsetOutRows;
  671. ÊÊÊ short centerInColumns, centerInRows;
  672. ÊÊÊ short offsetInColumns, offsetInRows;
  673. ÊÊÊ short difColumns, difRows;ÊÊÊ
  674. ÊÊÊ short proxyCenterCol, proxyCenterRow;
  675. ÊÊÊ short proxyOffsetCol, proxyOffsetRow;
  676. ÊÊÊ int srcX,srcY ;
  677. ÊÊÊ int i,j,ii,jj,max,polo,plane;
  678. ÊÊÊ unsigned8 *dstPtr;
  679. ÊÊÊ unsigned8 *mskPtr;
  680. ÊÊÊ unsigned8 *mskPtr2;
  681. ÊÊÊ const short outColumns= gStuff->outRect.right - gStuff->outRect.left;
  682. ÊÊÊ const short outRows = gStuff->outRect.bottom - gStuff->outRect.top;ÊÊÊ
  683. ÊÊÊ const short outPlanes = gStuff->outHiPlane - gStuff->outLoPlane + 1;
  684. ÊÊÊ const short inColumns = gStuff->imageSize.h;
  685. ÊÊÊ const short inRows = gStuff->imageSize.v;
  686. ÊÊÊ const short inPlanes =gStuff->outHiPlane - gStuff->outLoPlane + 1;
  687. ÊÊÊ double pomoc;ÊÊÊ
  688. ÊÊÊ Boolean maskPixel = false;
  689. ÊÊÊ
  690. ÊÊÊ offsetOutColumns = outColumns / 2;
  691. ÊÊÊ offsetOutRows = outRows / 2;
  692. ÊÊÊ centerInColumns = inColumns / 2;
  693. ÊÊÊ centerInRows = inRows / 2;
  694. ÊÊÊ offsetInColumns = (short)(inColumns * gRepFactor / 2);
  695. ÊÊÊ offsetInRows = (short)(inRows * gRepFactor / 2);
  696. ÊÊÊ difColumnsÊÊÊÊÊÊÊ = offsetInColumns - offsetOutColumns;
  697. ÊÊÊ difRows = offsetInRows - offsetOutRows;
  698. difColumns /= (short)gRepFactor;
  699. ÊÊÊ difRows /=(short)gRepFactor;
  700. ÊÊÊ gPozice.x=gSPozice.x+(short)gDif.x;
  701. ÊÊÊ if (gPozice.x> difColumns) gPozice.x=difColumns;
  702. ÊÊÊ if (gPozice.x<-difColumns) gPozice.x=-difColumns;
  703. ÊÊÊ gPozice.y=gSPozice.y+(short)gDif.y;
  704. ÊÊÊ if (gPozice.y> difRows) gPozice.y=difRows;
  705. ÊÊÊ if (gPozice.y<-difRows) gPozice.y=-difRows;
  706. ÊÊÊ proxyCenterCol = gOrigProxyRect.left + ((gOrigProxyRect.right - gOrigProxyRect.left) / 4);
  707. ÊÊÊ proxyCenterRow = gOrigProxyRect.top + ((gOrigProxyRect.bottom - gOrigProxyRect.top) / 4);
  708. ÊÊÊ proxyOffsetCol = outColumns / 2;
  709. ÊÊÊ proxyOffsetRow = outRows / 2;
  710.  
  711. ÊÊÊ
  712. ÊÊÊ max=(int)sqrt((inRows/2)*(inRows/2)+(inColumns/2)*(inColumns/2));
  713. ÊÊÊ for (i = 0; i < outRows; i ++)
  714. ÊÊÊ {
  715. ÊÊÊÊÊÊÊ i--;
  716. ÊÊÊÊÊÊÊ for(ii = 1;ii<=gRepFactor;ii++)
  717. ÊÊÊÊÊÊÊ {
  718. ÊÊÊÊÊÊÊÊÊÊÊ i++;
  719. ÊÊÊÊÊÊÊÊÊÊÊ if(i==outRows) break;
  720. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2= (unsigned8 *)gSHOWmask + (i * outColumns);
  721. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr = (unsigned8 *)gStuff->outData + (i * outColumns * outPlanes); ÊÊÊÊÊÊÊ
  722. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr = (unsigned8 *)gFFTmask + (- gPozice.x + difColumns + (((int)(i/gRepFactor) + difRows - gPozice.y ) * inColumns));
  723. ÊÊÊÊÊÊÊÊÊÊÊ srcX= - gPozice.x + difColumns + (((int)(i/gRepFactor) + difRows - gPozice.y ) * inColumns);
  724. ÊÊÊÊÊÊÊÊÊÊÊ srcY=srcX-((short)(srcX/inColumns))*inColumns; ÊÊÊÊÊÊÊ
  725. ÊÊÊÊÊÊÊÊÊÊÊ for (j = 0; j < outColumns; j ++)
  726. ÊÊÊÊÊÊÊÊÊÊÊ {
  727. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ j--;
  728. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ for (jj = 1;jj<=gRepFactor;jj++)
  729. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ {
  730. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ if (gIMaska) mskPtr2[0] = 255-mskPtr[0];
  731. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ else mskPtr2[0]=255;
  732. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  733. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ if(!mask)
  734. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ {
  735. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ if (mskPtr[0]) for(plane=0;plane<inPlanes;plane++)  dstPtr[plane]=((gInten*gFFTdata[((srcX/inColumns)*inColumns+srcY)*inPlanes+plane]/100)+(100-gInten)*gFFTdata2[((srcX/inColumns)*inColumns+srcY)*inPlanes+plane]/100);  ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  736. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ else ÊÊÊÊÊÊÊ for(plane=0;plane<inPlanes;plane++) dstPtr[plane]=gFFTdata[((srcX/inColumns)*inColumns+srcY)*inPlanes+plane];
  737. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ }
  738. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr2++;
  739. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ dstPtr +=outPlanes;
  740. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ j++;
  741. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ if (j==outColumns) break;
  742. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ }
  743. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ srcY ++;
  744. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr++;
  745. ÊÊÊÊÊÊÊÊÊÊÊ }
  746. ÊÊÊÊÊÊÊ }
  747. ÊÊÊ }
  748. ÊÊÊ
  749. ÊÊÊ gProxyRect.left = proxyCenterCol - proxyOffsetCol > gOrigProxyRect.left
  750. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterCol - proxyOffsetCol : gOrigProxyRect.left;
  751. ÊÊÊ gProxyRect.right = proxyCenterCol + proxyOffsetCol < gOrigProxyRect.right
  752. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterCol + proxyOffsetCol : gOrigProxyRect.right;
  753. ÊÊÊ gProxyRect.top = proxyCenterRow - proxyOffsetRow > gOrigProxyRect.top
  754. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterRow - proxyOffsetRow : gOrigProxyRect.top;
  755. ÊÊÊ gProxyRect.bottom = proxyCenterRow + proxyOffsetRow < gOrigProxyRect.bottom
  756. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterRow + proxyOffsetRow : gOrigProxyRect.bottom;
  757. }
  758. ÊÊÊ
  759. /*****************************************************************************/
  760. /* Zoom Out. Zmen?en’ gRepFactor between 0...1. */
  761.  
  762. void ZoomOutRect (GPtr globals,ÊÊÊ Boolean mask)
  763. {
  764. ÊÊÊ const unsigned8 kUIBackcolor = 191;
  765. ÊÊÊ short offsetOutColumns, offsetOutRows;
  766. ÊÊÊ short startOutColumns, startOutRows, endOutColumns, endOutRows;
  767. ÊÊÊ const short outColumns= gStuff->outRect.right - gStuff->outRect.left;
  768. ÊÊÊ const short outRows = gStuff->outRect.bottom - gStuff->outRect.top;ÊÊÊ
  769. ÊÊÊ const short outPlanes = gStuff->outHiPlane - gStuff->outLoPlane + 1;
  770. ÊÊÊ const short inColumns = gStuff->imageSize.h;
  771. ÊÊÊ const short inRows = gStuff->imageSize.v;
  772. ÊÊÊ const short inPlanes = gStuff->inHiPlane - gStuff->inLoPlane + 1;
  773. ÊÊÊ short centerInColumns, centerInRows;
  774. ÊÊÊ short offsetInColumns, offsetInRows;
  775. ÊÊÊ short difColumns, difRows;
  776. short offset = 0;
  777. ÊÊÊ short proxyCenterCol, proxyCenterRow;
  778. ÊÊÊ short proxyOffsetCol, proxyOffsetRow;
  779. ÊÊÊ float HFactor = 0;
  780. float VFactor = 0;
  781. ÊÊÊ double pomoc;
  782. ÊÊÊ unsigned8 *dstPtr;
  783. ÊÊÊ unsigned8 *mskPtr;
  784. ÊÊÊ unsigned8 *mskPtr2;
  785. ÊÊÊ int i,j,srcX,srcY,max,polo,plane;
  786. ÊÊÊ Boolean maskPixel = false;
  787. ÊÊÊ
  788. ÊÊÊ offsetOutColumns = outColumns / 2;
  789. ÊÊÊ offsetOutRows = outRows / 2;
  790. ÊÊÊ startOutColumns = 0;
  791. ÊÊÊ startOutRows = 0;
  792. ÊÊÊ endOutColumns = outColumns-1;
  793. ÊÊÊ endOutRows = outRows-1;
  794. ÊÊÊ centerInColumns = inColumns / 2;
  795. ÊÊÊ centerInRows = inRows / 2;
  796. ÊÊÊ offsetInColumns = (short)(inColumns * gRepFactor / 2);
  797. ÊÊÊ offsetInRows = (short)(inRows * gRepFactor / 2);
  798. ÊÊÊ difColumnsÊÊÊÊÊÊÊ = offsetInColumns - offsetOutColumns;
  799. ÊÊÊ difRows = offsetInRows - offsetOutRows;
  800.  
  801. ÊÊÊ
  802.  
  803. ÊÊÊ if (difColumns<0)
  804. ÊÊÊ {
  805. ÊÊÊÊÊÊÊ difColumns++;
  806. ÊÊÊÊÊÊÊ startOutColumns-=difColumns;
  807. ÊÊÊÊÊÊÊ difColumns--;
  808. ÊÊÊÊÊÊÊ endOutColumns+=difColumns;
  809. ÊÊÊÊÊÊÊ difColumns=0;
  810. ÊÊÊ }
  811. ÊÊÊ if (difRows<0)
  812. ÊÊÊ {
  813. ÊÊÊÊÊÊÊ difRows++;
  814. ÊÊÊÊÊÊÊ startOutRows-=difRows;
  815. ÊÊÊÊÊÊÊ difRows--;
  816. ÊÊÊÊÊÊÊ endOutRows+=difRows;
  817. ÊÊÊÊÊÊÊ difRows=0;
  818. ÊÊÊ }
  819. ÊÊÊ gPozice.x=gSPozice.x+(short)gDif.x;
  820. ÊÊÊ if (gPozice.x> difColumns) gPozice.x=difColumns;
  821. ÊÊÊ if (gPozice.x<-difColumns) gPozice.x=-difColumns;
  822. ÊÊÊ gPozice.y=gSPozice.y+(short)gDif.y;
  823. ÊÊÊ if (gPozice.y> difRows) gPozice.y=difRows;
  824. ÊÊÊ if (gPozice.y<-difRows) gPozice.y=-difRows;
  825. ÊÊÊ proxyCenterCol = gOrigProxyRect.left + ((gOrigProxyRect.right - gOrigProxyRect.left) / 2);
  826. ÊÊÊ proxyCenterRow = gOrigProxyRect.top + ((gOrigProxyRect.bottom - gOrigProxyRect.top) / 2);
  827. ÊÊÊ proxyOffsetCol = (short)((outColumns * gRepFactor) / 2);
  828. ÊÊÊ proxyOffsetRow = (short)((outRows * gRepFactor) / 2);
  829. ÊÊÊ if (!mask)
  830. ÊÊÊ {
  831. ÊÊÊÊÊÊÊ for (i = 0;i < startOutRows;i ++)
  832. ÊÊÊÊÊÊÊ {
  833. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr = (unsigned8 *) gStuff->outData + (i * outColumns* outPlanes);
  834. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2= (unsigned8 *) gSHOWmask + (i * outColumns);
  835. ÊÊÊÊÊÊÊÊÊÊÊ for (j = 0; j < outColumns; j ++)
  836. ÊÊÊÊÊÊÊ {
  837. ÊÊÊÊÊÊÊÊÊÊÊ for(plane=0;plane<inPlanes;plane++) dstPtr [plane] = kUIBackcolor;
  838. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2[0]=255;
  839. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr +=outPlanes;
  840. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2++;
  841. ÊÊÊÊÊÊÊÊÊÊÊ }
  842. ÊÊÊÊÊÊÊ }
  843. ÊÊÊ }
  844. ÊÊÊ max=(int)sqrt((inRows/2)*(inRows/2)+(inColumns/2)*(inColumns/2));
  845. ÊÊÊ for (i = startOutRows;i < endOutRows; i ++)
  846. ÊÊÊ {
  847. ÊÊÊÊÊÊÊ srcX = (short)((-gPozice.x+difColumns)/gRepFactor) + ((i - startOutRows + (short)((-gPozice.y+difRows)/gRepFactor) + offset) * inColumns );
  848. ÊÊÊÊÊÊÊ dstPtr = (unsigned8 *) gStuff->outData + (i * outColumns* outPlanes);
  849. ÊÊÊ mskPtr2= (unsigned8 *) gSHOWmask + (i * outColumns);
  850. ÊÊÊÊÊÊÊ mskPtr = (unsigned8 *) gFFTmask + (short)((-gPozice.x+difColumns)/gRepFactor) + ((i - startOutRows + (short)((-gPozice.y + difRows)/gRepFactor) + offset) * inColumns);
  851. ÊÊÊÊÊÊÊ HFactor=0;
  852. ÊÊÊÊÊÊÊ for (j = 0; j < startOutColumns;j ++)
  853. ÊÊÊÊÊÊÊ {
  854. ÊÊÊÊÊÊÊÊÊÊÊ for(plane=0;plane<inPlanes;plane++) dstPtr [plane] = kUIBackcolor;
  855. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2[0]=255;
  856. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr += outPlanes;
  857. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2++;
  858. ÊÊÊÊÊÊÊ }
  859. ÊÊÊÊÊÊÊ srcY=srcX-((short)(srcX/inColumns))*inColumns; ÊÊÊÊÊÊÊ
  860. ÊÊÊÊÊÊÊ for (j = startOutColumns;j < endOutColumns; j ++)
  861. ÊÊÊÊÊÊÊ { ÊÊÊÊÊÊÊÊÊÊÊ
  862. ÊÊÊÊÊÊÊÊÊÊÊ if (gIMaska) mskPtr2[0] = 255-mskPtr[0];
  863. ÊÊÊÊÊÊÊÊÊÊÊ else mskPtr2[0]=255;
  864. ÊÊÊÊÊÊÊ
  865. ÊÊÊÊÊÊÊÊÊÊÊ if(!mask)
  866. ÊÊÊÊÊÊÊÊÊÊÊ {
  867. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ if(mskPtr[0]) for(plane=0;plane<inPlanes;plane++) dstPtr[plane]=((gInten*gFFTdata[((srcX/inColumns)*inColumns+srcY)*inPlanes+plane]/100)+(100-gInten)*gFFTdata2[((srcX/inColumns)*inColumns+srcY)*inPlanes+plane]/100);  ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  868. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ else ÊÊÊÊÊÊÊ for(plane=0;plane<inPlanes;plane++) dstPtr[plane]=gFFTdata[((srcX/inColumns)*inColumns+srcY)*inPlanes+plane];
  869. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
  870. ÊÊÊÊÊÊÊÊÊÊÊ }
  871. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr +=outPlanes;
  872. ÊÊÊÊÊÊÊÊÊÊÊ srcY ++;
  873. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr++;
  874. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2++;
  875. ÊÊÊÊÊÊÊÊÊÊÊ HFactor += ((1/gRepFactor)-1);
  876. ÊÊÊÊÊÊÊÊÊÊÊ while(HFactor>=0.5)
  877. {
  878. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ HFactor-=1;
  879. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ srcY ++;
  880. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr++;
  881. }
  882. ÊÊÊÊÊÊÊ }
  883. ÊÊÊÊÊÊÊ if(!mask)
  884. ÊÊÊÊÊÊÊ {
  885. ÊÊÊÊÊÊÊÊÊÊÊ for (j = endOutColumns; j < outColumns; j ++)
  886. ÊÊÊÊÊÊÊÊÊÊÊ {
  887. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ for(plane=0;plane<inPlanes;plane++) dstPtr [plane] = kUIBackcolor;
  888. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr2[0]=255;
  889. ÊÊÊÊÊÊÊÊÊÊÊ
  890. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ dstPtr += outPlanes;
  891. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr2++;
  892. ÊÊÊÊÊÊÊÊÊÊÊ }
  893. ÊÊÊÊÊÊÊ }
  894. ÊÊÊÊÊÊÊ VFactor += ((1/gRepFactor)-1);
  895. ÊÊÊÊÊÊÊ while(VFactor>=0.5)
  896. ÊÊÊÊÊÊÊ {
  897. ÊÊÊÊÊÊÊÊÊÊÊ VFactor-=1;
  898. ÊÊÊÊÊÊÊÊÊÊÊ offset+=1;
  899. ÊÊÊÊÊÊÊ }
  900. ÊÊÊ }
  901. ÊÊÊ if(!mask)
  902. ÊÊÊ {
  903. ÊÊÊÊÊÊÊ for (i = endOutRows; i < outRows; i ++)
  904. ÊÊÊÊÊÊÊ {
  905. ÊÊÊÊÊÊÊÊÊÊÊ dstPtr = (unsigned8 *) gStuff->outData + (i * outColumns* outPlanes);
  906. ÊÊÊÊÊÊÊÊÊÊÊ mskPtr2= (unsigned8 *) gSHOWmask + (i * outColumns);
  907.  
  908. ÊÊÊÊÊÊÊÊÊÊÊ for (j = 0; j < outColumns; j ++)
  909. ÊÊÊÊÊÊÊÊÊÊÊ {
  910. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ for(plane=0;plane<inPlanes;plane++) dstPtr [plane] = kUIBackcolor;ÊÊÊ
  911. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr2[0]=255;
  912. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ dstPtr += outPlanes;
  913. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ mskPtr2++;
  914. ÊÊÊÊÊÊÊÊÊÊÊ }
  915. ÊÊÊÊÊÊÊ }
  916. ÊÊÊ }
  917.  
  918.  
  919. ÊÊÊ gProxyRect.left = proxyCenterCol - proxyOffsetCol > gOrigProxyRect.left
  920. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterCol - proxyOffsetCol : gOrigProxyRect.left;
  921. ÊÊÊ gProxyRect.right = proxyCenterCol + proxyOffsetCol < gOrigProxyRect.right
  922. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterCol + proxyOffsetCol : gOrigProxyRect.right;
  923. ÊÊÊ gProxyRect.top = proxyCenterRow - proxyOffsetRow > gOrigProxyRect.top
  924. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ ? proxyCenterRow - proxyOffsetRow : gOrigProxyRect.top;
  925. ÊÊÊ gProxyRect.bottom = proxyCenterRow + proxyOffsetRow < gOrigProxyRect.bottom;
  926. }
  927. ÊÊÊ
  928. /*****************************************************************************/
  929. /* Zooms in by one factor (parts of 1.0 until 1.0, then 1.0, 2.0, etc. */
  930.  
  931. void ZoomIn (short *zoom)
  932. {
  933. ÊÊÊ if (*zoom >= kNumZooms)
  934. ÊÊÊÊÊÊÊ *zoom += kNumZooms;
  935. ÊÊÊ else (*zoom)++;
  936. }
  937.  
  938. void ZoomOut (short *zoom)
  939. {
  940. ÊÊÊ if (*zoom >= (kNumZooms*2))
  941. ÊÊÊÊÊÊÊ *zoom -= kNumZooms;
  942. ÊÊÊ else (*zoom)--;
  943. }
  944.  
  945. /*****************************************************************************/
  946. /* Takes an enumeration and returns corresponding zoom size */
  947.  
  948. short GetZoomFactor (GPtr globals)
  949. {
  950. ÊÊÊ shortÊÊÊ sub = 0;
  951. ÊÊÊ shortÊÊÊ returnValue = noErr;
  952. ÊÊÊ
  953. ÊÊÊ /* check for zoomFactor bounds */
  954. ÊÊÊ
  955. ÊÊÊ if (gZoomFactor <= kMinZoom)
  956. ÊÊÊ {
  957. ÊÊÊÊÊÊÊ gZoomFactor = kMinZoom;
  958. ÊÊÊÊÊÊÊ returnValue = hitLowBounds;
  959. ÊÊÊ }
  960. ÊÊÊ else if (gZoomFactor >= kMaxZoom)
  961. ÊÊÊ {
  962. ÊÊÊÊÊÊÊ gZoomFactor = kMaxZoom;
  963. ÊÊÊÊÊÊÊ returnValue = hitHighBounds;
  964. ÊÊÊ }
  965. ÊÊÊ
  966. ÊÊÊ sub = gZoomFactor % kNumZooms;
  967. ÊÊÊ
  968. ÊÊÊ switch (sub)
  969. ÊÊÊÊÊÊÊ {
  970. ÊÊÊÊÊÊÊÊÊÊÊ case 1:
  971. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gRepFactor = (float)0.25;
  972. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ break;
  973. ÊÊÊÊÊÊÊÊÊÊÊ case 2:
  974. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gRepFactor = (float)0.33;
  975. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ break;
  976. ÊÊÊÊÊÊÊÊÊÊÊ case 3:
  977. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gRepFactor = (float)0.50;
  978. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ break;
  979. ÊÊÊÊÊÊÊÊÊÊÊ case 4:
  980. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gRepFactor = (float)0.66;
  981. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ break;
  982. ÊÊÊÊÊÊÊÊÊÊÊ case 5:
  983. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gRepFactor = (float)0.80;
  984. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ break;
  985. ÊÊÊÊÊÊÊÊÊÊÊ default:
  986. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gRepFactor = (float)0;
  987. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ break;
  988. ÊÊÊÊÊÊÊ }
  989. ÊÊÊÊÊÊÊ gRepFactor += gZoomFactor / kNumZooms;
  990. ÊÊÊ return returnValue;
  991. }
  992.  
  993.  
  994. void scaleRect(Rect *l, short n, short d) {
  995. ÊÊÊ l->left = (l->left * n) / d;
  996. ÊÊÊ l->top = (l->top * n) / d;
  997. ÊÊÊ l->right = (l->right * n) / d;
  998. ÊÊÊ l->bottom = (l->bottom * n) / d;
  999. }
  1000.  
  1001. void shrinkRect(Rect *l, short x, short y) {
  1002. ÊÊÊ l->left += x;
  1003. ÊÊÊ l->top += y;
  1004. ÊÊÊ l->right -= x;
  1005. ÊÊÊ l->bottom -= y;
  1006. }
  1007.  
  1008. void copyRect(Rect *l, const Rect *r) {
  1009. ÊÊÊ l->left = r->left;
  1010. ÊÊÊ l->top = r->top;
  1011. ÊÊÊ l->right = r->right;
  1012. ÊÊÊ l->bottom = r->bottom;
  1013. }
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030. /******************************************************************************/
  1031. /* NEPOU?ITO - Pokud se filtruje po ?‡stech */
  1032.  
  1033. void StartNoAdvanceState (GPtr globals)
  1034. {
  1035. ÊÊÊ DoInitialRect(globals);
  1036. }
  1037.  
  1038. /*****************************************************************************/
  1039. /* NEPOU?ITO - inicializace prvn’ filtrovanŽ ?‡sti - filtrov‡n’ po ?‡stech */
  1040.  
  1041. void DoInitialRect (GPtr globals)
  1042. {
  1043. ÊÊÊ int32 total;
  1044. ÊÊÊ total = gStuff->filterRect.bottom - gStuff->filterRect.top;
  1045. ÊÊÊ gStuff->inLoPlane = gStuff->outLoPlane = 0;
  1046. ÊÊÊ gStuff->inHiPlane = gStuff->outHiPlane = gStuff->planes - 1;
  1047. ÊÊÊ
  1048. ÊÊÊ /* Pou?’t’ Alfa kan‡l? */
  1049. ÊÊÊ #if useAlpha
  1050. ÊÊÊ if (!gStuff->isFloating)
  1051. ÊÊÊ {
  1052. ÊÊÊÊÊÊÊ gStuff->wantsAbsolute = true;
  1053. ÊÊÊÊÊÊÊ if (gStuff->inLayerPlanes !=0 && gStuff->inTransparencyMask != 0)
  1054. ÊÊÊÊÊÊÊÊÊÊÊ gStuff->inHiPlane = gStuff->absLayerPlanes - 1 +
  1055. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absTransparencyMask +
  1056. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absLayerMasks +
  1057. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absInvertedLayerMasks +
  1058. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->absNonLayerPlanes;
  1059. ÊÊÊÊÊÊÊ
  1060. ÊÊÊÊÊÊÊ if (gStuff->outLayerPlanes !=0 && gStuff->outTransparencyMask !=0)
  1061. ÊÊÊÊÊÊÊÊÊÊÊ gStuff->outHiPlane = gStuff->outLayerPlanes - 1 +
  1062. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outTransparencyMask +
  1063. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outLayerMasks +
  1064. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outInvertedLayerMasks +
  1065. ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ gStuff->outNonLayerPlanes;
  1066. ÊÊÊ }
  1067. ÊÊÊ #endif
  1068. ÊÊÊ gStuff->inputRate = long2fixed (1L);
  1069. ÊÊÊ gStuff->maskRate = long2fixed (1L);
  1070. ÊÊÊ gStuff->maskPadding = gStuff->outputPadding = gStuff->inputPadding = 255;
  1071. ÊÊÊ gStuff->inRect = gStuff->outRect = gStuff->maskRect = gStuff->filterRect;
  1072. ÊÊÊ gStuff->inRect.bottom = gStuff->outRect.bottom = gStuff->maskRect.bottom = gStuff->inRect.top + gRowSkip;
  1073. }
  1074.  
  1075. /*****************************************************************************/
  1076. /* NEPOU?ITO - Dotaz na dal?’ ?‡st */
  1077.  
  1078. Boolean DoNextRect (GPtr globals)
  1079. {
  1080. ÊÊÊ gStuff->inRect.top += gRowSkip; // next batch
  1081. ÊÊÊ gStuff->inRect.bottom += gRowSkip; // next batch
  1082. ÊÊÊ gStuff->outRect = gStuff->maskRect = gStuff->inRect;
  1083. ÊÊÊ
  1084. ÊÊÊ return gStuff->inRect.top < gStuff->filterRect.bottom;
  1085. }
  1086.  
  1087.  
  1088.