home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / image144.sit / Init.p < prev    next >
Encoding:
Text File  |  1992-03-30  |  34.7 KB  |  1,252 lines

  1. unit Initialization;
  2.  
  3. interface
  4.  
  5.  
  6.     uses
  7.         QuickDraw, Palettes, PrintTraps, Slots, globals, Utilities, Graphics, Lut;
  8.  
  9.     procedure Init;
  10.     procedure AllocateBuffers;
  11.     procedure AllocateArrays;
  12.     procedure SetupMenus;
  13.     procedure GetSettings;
  14.  
  15.  
  16.  
  17. implementation
  18.  
  19.  
  20.     procedure MakeCursors;
  21.   {Generates tool cursors from tool font. Thanks to Borland for "OffScreenDrawing"}
  22.   {and "MysteryCursor" examples in "Turbo Pascal Tutor".}
  23.         var
  24.             TempPort: GrafPort;
  25.             tPort: GrafPtr;
  26.             aRect, bRect: Rect;
  27.             OffScreenBitMap: BitMap;
  28.             BlankMask: Bits16;
  29.             tool: ToolType;
  30.             i: integer;
  31.             TempCurH: CursHandle;
  32.     begin
  33.         GetPort(tPort);
  34.         OpenPort(@TempPort);
  35.         with OffScreenBitMap do begin
  36.                 baseAddr := NewPtr(2 * 16); { allocate a bit image for 16x16 cursor}
  37.                 rowBytes := 2;              { 2 bytes per row}
  38.                 SetRect(bounds, 0, 0, 16, 16);  { define usable area and coordinate systme }
  39.             end;
  40.         SetPortBits(OffscreenBitMap);
  41.         for i := 0 to 15 do
  42.             BlankMask[i] := 0;
  43.         TextFont(ToolFont);
  44.         TextSize(12);
  45.         for tool := FirstTool to LastTool do begin
  46.                 EraseRect(OffscreenBitMap.bounds);
  47.                 MoveTo(0, 0);
  48.                 DrawChar(ToolCursorChar[tool]);
  49.                 with ToolCursor[tool] do begin
  50.                         BlockMove(OffscreenBitMap.BaseAddr, @data, 32);
  51.                         hotspot.h := 8;
  52.                         hotspot.v := 8;
  53.                         mask := BlankMask;
  54.                     end;
  55.             end;
  56.         ClosePort(@TempPort);
  57.         SetPort(tPort);
  58.  
  59.         TempCurH := GetCursor(PickerCursorID);
  60.         if TempCurH <> nil then begin
  61.                 PickerCursor := TempCurH^^;
  62.                 ToolCursor[PickerTool] := PickerCursor;
  63.                 ReleaseResource(handle(TempCurH));
  64.             end;
  65.  
  66.         TempCurH := GetCursor(CrossCursorPlusID);
  67.         if TempCurH <> nil then begin
  68.                 CrossPlusCursor := TempCurH^^;
  69.                 ReleaseResource(handle(TempCurH));
  70.             end;
  71.  
  72.         TempCurH := GetCursor(CrossCursorMinusID);
  73.         if TempCurH <> nil then begin
  74.                 CrossMinusCursor := TempCurH^^;
  75.                 ReleaseResource(handle(TempCurH));
  76.             end;
  77.  
  78.         TempCurH := GetCursor(WandPlusCursorID);
  79.         if TempCurH <> nil then begin
  80.                 WandPlusCursor := TempCurH^^;
  81.                 ReleaseResource(handle(TempCurH));
  82.             end;
  83.  
  84.         TempCurH := GetCursor(WandMinusCursorID);
  85.         if TempCurH <> nil then begin
  86.                 WandMinusCursor := TempCurH^^;
  87.                 ReleaseResource(handle(TempCurH));
  88.             end;
  89.  
  90.         TempCurH := GetCursor(CrossCursorID);
  91.         if TempCurH <> nil then begin
  92.                 ToolCursor[SelectionTool] := TempCurH^^;
  93.                 ToolCursor[FreehandTool] := TempCurH^^;
  94.                 ToolCursor[PolygonTool] := TempCurH^^;
  95.                 ToolCursor[ruler] := TempCurH^^;
  96.                 ToolCursor[PlotTool] := TempCurH^^;
  97.                 ToolCursor[OvalSelectionTool] := TempCurH^^;
  98.                 ToolCursor[LineTool] := TempCurH^^;
  99.                 ToolCursor[AngleTool] := TempCurH^^;
  100.                 ToolCursor[CrossHairTool] := TempCurH^^;
  101.                 ReleaseResource(handle(TempCurH));
  102.             end;
  103.  
  104.         TempCurH := GetCursor(LUTCursorID);
  105.         if TempCurH <> nil then begin
  106.                 LUTCursor := TempCurH^^;
  107.                 ReleaseResource(handle(TempCurH));
  108.             end;
  109.  
  110.         TempCurH := GetCursor(gmCursorID);
  111.         if TempCurH <> nil then begin
  112.                 gmCursor := TempCurH^^;
  113.                 ReleaseResource(handle(TempCurH));
  114.             end;
  115.  
  116.         TempCurH := GetCursor(GrabberCursorID);
  117.         if TempCurH <> nil then begin
  118.                 ToolCursor[Grabber] := TempCurH^^;
  119.                 ReleaseResource(handle(TempCurH));
  120.             end;
  121.  
  122.         TempCurH := GetCursor(PencilCursorID);
  123.         if TempCurH <> nil then begin
  124.                 ToolCursor[Pencil] := TempCurH^^;
  125.                 ReleaseResource(handle(TempCurH));
  126.             end;
  127.  
  128.         TempCurH := GetCursor(GlassCursorPlusID);
  129.         if TempCurH <> nil then begin
  130.                 ToolCursor[MagnifyingGlass] := TempCurH^^;
  131.                 ReleaseResource(handle(TempCurH));
  132.             end;
  133.  
  134.         TempCurH := GetCursor(GlassCursorMinusID);
  135.         if TempCurH <> nil then begin
  136.                 GlassMinusCursor := TempCurH^^;
  137.                 ReleaseResource(handle(TempCurH));
  138.             end;
  139.  
  140.         TempCurH := GetCursor(BucketCursorID);
  141.         if TempCurH <> nil then begin
  142.                 ToolCursor[PaintBucket] := TempCurH^^;
  143.                 ReleaseResource(handle(TempCurH));
  144.             end;
  145.  
  146.         TempCurH := GetCursor(WandCursorID);
  147.         if TempCurH <> nil then begin
  148.                 ToolCursor[Wand] := TempCurH^^;
  149.                 ReleaseResource(handle(TempCurH));
  150.             end;
  151.  
  152.         TempCurH := GetCursor(WatchCursor);
  153.         if TempCurH <> nil then begin
  154.                 watch := TempCurH^^;
  155.                 ReleaseResource(handle(TempCurH));
  156.             end;
  157.     end;
  158.  
  159.  
  160.     procedure InitTools;
  161.         var
  162.             ToolTop, LinesTop, i: integer;
  163.             Tool: ToolType;
  164.     begin
  165.         FirstTool := MagnifyingGlass;
  166.         LastTool := CrossHairTool;
  167.         CurrentTool := SelectionTool;
  168.         isSelectionTool := true;
  169.         PreviousTool := CurrentTool;
  170.         ToolTop := 0;
  171.         for tool := FirstTool to LastTool do
  172.             with ToolRect[tool] do begin
  173.                     top := ToolTop;
  174.                     bottom := top + tmiddle;
  175.                     if odd(ord(tool) + 1) then
  176.                         left := 0
  177.                     else begin
  178.                             left := tmiddle;
  179.                             ToolTop := ToolTop + tmiddle;
  180.                         end;
  181.                     right := left + tmiddle;
  182.                 end;
  183.         ToolChar[Pencil] := chr(76);
  184.         ToolChar[SelectionTool] := chr(70);
  185.         ToolChar[MagnifyingGlass] := chr(66);
  186.         ToolChar[TextTool] := chr(72);
  187.         ToolChar[Grabber] := chr(71);
  188.         ToolChar[Brush] := chr(75);
  189.         ToolChar[ruler] := chr(112);
  190.         ToolChar[PaintBucket] := chr(104);
  191.         ToolChar[AirBrushTool] := chr(74);
  192.         ToolChar[PlotTool] := chr(94);
  193.         ToolChar[Wand] := chr(101);
  194.         ToolChar[Eraser] := chr(78);
  195.         ToolChar[FreehandTool] := chr(69);
  196.         ToolChar[PolygonTool] := chr(87);
  197.         ToolChar[OvalSelectionTool] := chr(83);
  198.         ToolChar[PickerTool] := chr(77);
  199.         ToolChar[LineTool] := chr(StraightChar);
  200.         ToolChar[LUTTool] := chr(86);
  201.         ToolChar[AngleTool] := chr(106);
  202.         ToolChar[CrossHairTool] := chr(113);
  203.         ToolCursorChar[SelectionTool] := chr(89);
  204.         ToolCursorChar[Pencil] := chr(76);
  205.         ToolCursorChar[MagnifyingGlass] := chr(66);
  206.         ToolCursorChar[TextTool] := chr(110);
  207.         ToolCursorChar[Grabber] := chr(71);
  208.         ToolCursorChar[brush] := chr(103);
  209.         ToolCursorChar[ruler] := chr(89);
  210.         ToolCursorChar[PaintBucket] := chr(89);
  211.         ToolCursorChar[LineTool] := chr(89);
  212.         ToolCursorChar[LUTTool] := chr(86);
  213.         ToolCursorChar[FreehandTool] := chr(89);
  214.         ToolCursorChar[AirbrushTool] := chr(100);
  215.         ToolCursorChar[PolygonTool] := chr(89);
  216.         ToolCursorChar[PlotTool] := chr(89);
  217.         ToolCursorChar[Wand] := chr(100);
  218.         ToolCursorChar[Eraser] := chr(68);
  219.         ToolCursorChar[OvalSelectionTool] := chr(89);
  220.         ToolCursorChar[PickerTool] := chr(77);
  221.         ToolCursorChar[AngleTool] := chr(89);
  222.         ToolCursorChar[CrossHairTool] := chr(89);
  223.         ToolTime := 0;
  224.         LutTime := 0;
  225.         StartOfLines := ToolRect[LastTool].bottom - 1;
  226.         LinesTop := StartOfLines + 10;
  227.         for i := 1 to nLineTypes do
  228.             with lines[i] do begin
  229.                     left := LinesLeft;
  230.                     top := LinesTop;
  231.                     right := LinesRight;
  232.                     case i of
  233.                         1, 2, 3, 4: 
  234.                             bottom := top + i;
  235.                         5: 
  236.                             bottom := top + 6;
  237.                         6: 
  238.                             bottom := top + 8
  239.                     end;
  240.                     LinesTop := bottom + 4;
  241.                 end;
  242.         LineWidth := 1;
  243.         LineIndex := 1;
  244.         with CheckRect do begin
  245.                 left := 0;
  246.                 top := StartOfLines;
  247.                 right := LinesLeft;
  248.                 bottom := theight;
  249.             end;
  250.     end;
  251.  
  252.  
  253.     procedure AllocateBuffers;
  254.         var
  255.             tPort: GrafPtr;
  256.             err: OSErr;
  257.             BufSizeStr: str255;
  258.             atemp: integer;
  259.     begin
  260.         GetPort(tPort);
  261.         NumToString(BufferSize div 1024, BufSizeStr);
  262.         BigBufSize := BufferSize * 2;
  263.         if FreeMem > (BigBufSize + 300000) then
  264.             BigBuf := NewPtr(BigBufSize)
  265.         else
  266.             BigBuf := nil;
  267.         if BigBuf = nil then
  268.             BigBufSize := 0;
  269.         if BigBuf <> nil then
  270.             UndoBuf := BigBuf
  271.         else begin
  272.                 if FreeMem > (BufferSize + 200000) then
  273.                     UndoBuf := NewPtr(BufferSize)
  274.                 else
  275.                     UndoBuf := nil;
  276.             end;
  277.         if UndoBuf <> nil then
  278.             UndoBufSize := BufferSize
  279.         else begin
  280.                 PutMessage(concat('There is not enough memory available to allocate the ', BufSizeStr, 'K Undo buffer. Many operations may fail or be Undoable.'));
  281.                 UndoBufSize := 0;
  282.             end;
  283.         if BigBuf <> nil then
  284.             ClipBuf := ptr(ord4(BigBuf) + BufferSize)
  285.         else begin
  286.                 if FreeMem > (BufferSize + 300000) then
  287.                     ClipBuf := NewPtr(BufferSize)
  288.                 else
  289.                     ClipBuf := nil;
  290.             end;
  291.         UndoInfoRec := NoInfo^;
  292.         UndoInfo := @UndoInfoRec;
  293.         if UndoBuf <> nil then
  294.             with UndoInfo^ do begin
  295.                     roiRgn := NewRgn;
  296.                     PicBaseAddr := UndoBuf;
  297.                     new(osPort);
  298.                     OpenCPort(osPort);
  299.                     osPort^.portPixMap^^.BaseAddr := PicBaseAddr;
  300.                     SetPalette(WindowPtr(osPort), ExplicitPalette, false);
  301.                 end;
  302.         if ClipBuf <> nil then begin
  303.                 ClipBufSize := BufferSize;
  304.                 ClipBufInfoRec := NoInfo^;
  305.                 ClipBufInfo := @ClipBufInfoRec;
  306.                 with ClipBufInfo^ do begin
  307.                         roiRgn := NewRgn;
  308.                         PicBaseAddr := ClipBuf;
  309.                         new(osPort);
  310.                         OpenCPort(osPort);
  311.                         osPort^.portPixMap^^.BaseAddr := PicBaseAddr;
  312.                         BytesPerRow := 0;
  313.                         SetPalette(WindowPtr(osPort), ExplicitPalette, false);
  314.                     end;
  315.             end
  316.         else begin
  317.                 PutMessage(concat('There is not enough memory available to allocate the ', BufSizeStr, 'K Clipboard Buffer. Many operations, including Copy and Paste, may fail.'));
  318.                 ClipBufSize := 0;
  319.             end;
  320.         SetPort(tPort);
  321.     end;
  322.  
  323.  
  324.     procedure AllocateArrays;
  325.         var
  326.             nItems: LongInt;
  327.             i: integer;
  328.  
  329.         procedure Abort;
  330.         begin
  331.             PutMessage('Not enough memory available to allocate arrays.');
  332.             ExitToShell;
  333.         end;
  334.  
  335.     begin
  336.         PlotData := LinePtr(NewPtr(MaxLine));
  337.         if PlotData = nil then
  338.             abort;
  339.         BlankLine := LinePtr(NewPtr(MaxLine));
  340.         if BlankLine = nil then
  341.             abort;
  342.         for i := 0 to MaxLine - 1 do
  343.             BlankLine^[i] := WhiteIndex;
  344.         xCoordinates := xCoordinatesPtr(NewPtr(SizeOf(CoordinatesType)));
  345.         if xCoordinates = nil then
  346.             abort;
  347.         yCoordinates := yCoordinatesPtr(NewPtr(SizeOf(CoordinatesType)));
  348.         if yCoordinates = nil then
  349.             abort;
  350.         nItems := MaxRegions + 1;
  351.         mean := meanPtr(NewPtr(nItems * SizeOf(real)));
  352.         if mean = nil then
  353.             abort;
  354.         sd := sdPtr(NewPtr(nItems * SizeOf(real)));
  355.         if sd = nil then
  356.             abort;
  357.         PixelCount := PixelCountPtr(NewPtr(nItems * SizeOf(LongInt)));
  358.         if PixelCount = nil then
  359.             abort;
  360.         mArea := AreaPtr(NewPtr(nItems * SizeOf(real)));
  361.         if mArea = nil then
  362.             abort;
  363.         mode := modePtr(NewPtr(nItems * SizeOf(real)));
  364.         if mode = nil then
  365.             abort;
  366.         IntegratedDensity := IntegratedDensityPtr(NewPtr(nItems * SizeOf(real)));
  367.         if IntegratedDensity = nil then
  368.             abort;
  369.         idBackground := idBackgroundPtr(NewPtr(nItems * SizeOf(real)));
  370.         if idBackground = nil then
  371.             abort;
  372.         xcenter := xcenterPtr(NewPtr(nItems * SizeOf(real)));
  373.         if xcenter = nil then
  374.             abort;
  375.         ycenter := ycenterPtr(NewPtr(nItems * SizeOf(real)));
  376.         if ycenter = nil then
  377.             abort;
  378.         MajorAxis := MajorAxisPtr(NewPtr(nItems * SizeOf(real)));
  379.         if MajorAxis = nil then
  380.             abort;
  381.         MinorAxis := MinorAxisPtr(NewPtr(nItems * SizeOf(real)));
  382.         if MinorAxis = nil then
  383.             abort;
  384.         orientation := orientationPtr(NewPtr(nItems * SizeOf(real)));
  385.         if orientation = nil then
  386.             abort;
  387.         mMin := MinPtr(NewPtr(nItems * SizeOf(real)));
  388.         if mMin = nil then
  389.             abort;
  390.         mMax := MaxPtr(NewPtr(nItems * SizeOf(real)));
  391.         if mMax = nil then
  392.             abort;
  393.         plength := plengthPtr(NewPtr(nItems * SizeOf(real)));
  394.         if plength = nil then
  395.             abort;
  396.         User1 := User1Ptr(NewPtr(nItems * SizeOf(real)));
  397.         if User1 = nil then
  398.             abort;
  399.         for i := 0 to MaxRegions do
  400.             User1^[i] := 0.0;
  401.         User2 := User2Ptr(NewPtr(nItems * SizeOf(real)));
  402.         if User2 = nil then
  403.             abort;
  404.         for i := 0 to MaxRegions do
  405.             User2^[i] := 0.0;
  406.         ClearResults(0);
  407.         if FreeMem < MinFree then
  408.             Abort;
  409.     end;
  410.  
  411.  
  412.     function OpenWD (vRefNum: integer; dirID: LongInt; procID: LongInt; var wdRefNum: integer): OSErr;
  413. {Converts a volume reference number and directory ID into a working directory reference number. See TN 218.}
  414.         var
  415.             theWD: WDPBRec;
  416.             err: OSErr;
  417.     begin
  418.         with theWD do begin
  419.                 ioCompletion := nil;
  420.                 ioNamePtr := nil;
  421.                 ioVRefNum := VRefNum;
  422.                 ioWDProcID := 0;
  423.                 ioWDDirID := DirID;
  424.                 err := PBOpenWD(@theWD, false);
  425.                 if err = NoErr then
  426.                     wdRefNum := ioVRefNum;
  427.                 OpenWD := err;
  428.             end; {with}
  429.     end;
  430.  
  431.  
  432.     procedure GetKernelsWorkingDir (var settings: SettingsType);
  433.         var
  434.             wdRefNum: integer;
  435.             err: OSErr;
  436.     begin
  437.         with settings do
  438.             if sKernelsVRefNum <> 0 then begin
  439.                     err := OpenWD(sKernelsVRefNum, sKernelsDirID, 0, wdRefNum);
  440.                     if err = NoErr then
  441.                         KernelsRefNum := wdRefNum;
  442.           {ShowMessage(concat('KernelsRefNum=', long2str(KernelsRefNum), cr, 'vRefNum=', long2str(sKernelsVRefNum), cr, 'DirID=', long2str(sKernelsDirID)));}
  443.                 end;
  444.     end;
  445.  
  446.  
  447.     procedure GetDefaultWorkingDir (var settings: SettingsType);
  448.         var
  449.             wdRefNum: integer;
  450.             err: OSErr;
  451.     begin
  452.         with settings do
  453.             if sDefaultVRefNum <> 0 then begin
  454.                     err := OpenWD(sDefaultVRefNum, sDefaultDirID, 0, wdRefNum);
  455.                     if err = NoErr then
  456.                         DefaultRefNum := wdRefNum;
  457.                 end;
  458.     end;
  459.  
  460.  
  461.     procedure GetSettings;
  462.         var
  463.             err: OSErr;
  464.             f: integer;
  465.             ByteCount: LongInt;
  466.             ok: boolean;
  467.             size: LongInt;
  468.             settings: SettingsType;
  469.     begin
  470.         err := fsopen(PrefsName, SystemRefNum, f);
  471.         if err <> NoErr then
  472.             exit(GetSettings);
  473.         err := GetEof(f, ByteCount);
  474.         if ByteCount > SizeOf(settings) then
  475.             ByteCount := SizeOf(settings);
  476.         err := fsRead(f, ByteCount, @settings);
  477.         if err <> NoErr then
  478.             exit(GetSettings);
  479.         err := fsClose(f);
  480.         with settings, info^ do begin
  481.                 if sID <> 'IMAG' then begin
  482.                         PutMessage('The Image Prefs file in the System folder is corrupted. Please delete it and try again.');
  483.                         exitToShell;
  484.                     end;
  485.                 if (ForegroundIndex <> sForegroundIndex) or (BackgroundIndex <> sBackgroundIndex) then begin
  486.                         SetForegroundColor(sForegroundIndex);
  487.                         SetBackgroundColor(sBackgroundIndex);
  488.                     end;
  489.                 BrushHeight := sBrushHeight;
  490.                 BrushWidth := sBrushWidth;
  491.                 AirbrushDiameter := sAirbrushDiameter;
  492.                 AirbrushRadius := AirbrushDiameter div 2;
  493.                 AirbrushRadius2 := AirbrushRadius * AirbrushRadius;
  494.                 CurrentFontID := sCurrentFontID;
  495.                 CurrentStyle := SCurrentStyle;
  496.                 CurrentSize := sCurrentSize;
  497.                 TextJust := sTextJust;
  498.                 TextBack := sTextBack;
  499.                 nExtraColors := sNExtraColors;
  500.                 ExtraColors := sExtraColors;
  501.                 InvertVideo := sInvertVideo;
  502.                 Measurements := sMeasurements;
  503.                 InvertPlots := sInvertPlots;
  504.                 AutoScalePlots := sAutoScalePlots;
  505.                 LinePlot := sLinePlot;
  506.                 DrawPlotLabels := sDrawPlotLabels;
  507.                 FixedSizePlot := sFixedSizePlot;
  508.                 ProfilePlotWidth := sProfilePlotWidth;
  509.                 ProfilePlotHeight := sProfilePlotHeight;
  510.                 FramesToAverage := sFramesToAverage;
  511.                 NewPicWidth := sNewPicWidth;
  512.                 NewPicHeight := sNewPicHeight;
  513.                 BufferSize := sBufferSize;
  514.                 MaxScionWidth := sMaxScionWidth;
  515.                 ThresholdToForeground := sThresholdToForeground;
  516.                 NonThresholdToBackground := sNonThresholdToBackground;
  517.                 VideoChannel := sVideoChannel;
  518.                 WhatToImport := sWhatToImport;
  519.                 ImportCustomWidth := sImportCustomWidth;
  520.                 ImportCustomHeight := sImportCustomHeight;
  521.                 ImportCustomOffset := sImportCustomOffset;
  522.                 WandAutoMeasure := sWandAutoMeasure;
  523.                 WandAdjustAreas := sWandAdjustAreas;
  524.                 BinaryIterations := sBinaryIterations;
  525.                 ScaleArithmetic := sScaleArithmetic;
  526.                 InvertPixelValues := sInvertPixelValues;
  527.                 InvertYCoordinates := sInvertYCoordinates;
  528.                 FieldWidth := sFieldWidth;
  529.                 precision := sPrecision;
  530.                 MinParticleSize := sMinParticleSize;
  531.                 MaxParticleSize := sMaxParticleSize;
  532.                 IgnoreParticlesTouchingEdge := sIgnoreParticlesTouchingEdge;
  533.                 LabelParticles := sLabelParticles;
  534.                 OutlineParticles := sOutlineParticles;
  535.                 IncludeHoles := sIncludeHoles;
  536.                 OscillatingMovies := sOscillatingMovies;
  537.                 DriverHalftoning := sDriverHalftoning;
  538.                 MaxRegions := sMaxRegions;
  539.                 ImportCustomDepth := sImportCustomDepth;
  540.                 ImportSwapBytes := sImportSwapBytes;
  541.                 ImportCalibrate := sImportCalibrate;
  542.                 ImportAutoscale := sImportAutoscale;
  543.                 ShowHeadings := sShowHeadings;
  544.                 if sVersion >= 140 then begin
  545.                         ProfilePlotMin := sProfilePlotMin;
  546.                         ProfilePlotMax := sProfilePlotMax;
  547.                         ImportMin := sImportMin;
  548.                         ImportMax := sImportMax;
  549.                         HighlightSaturatedPixels := sHighlightPixels;
  550.                     end;
  551.                 if sVersion >= 141 then begin
  552.                         BallRadius := sBallRadius;
  553.                         FasterBackgroundSubtraction := sFasterBackgroundSubtraction;
  554.                         ScaleConvolutions := sScaleConvolutions;
  555.                     end;
  556.                 if sVersion >= 142 then begin
  557.                         BinaryCount := sBinaryCount;
  558.                         BinaryThreshold := BinaryCount * 255;
  559.                         if (sLUTMode = Pseudocolor) and (sColorTable <> CustomTable) and (sColorTable <= Spectrum) then begin
  560.                                 SwitchColorTables(GetColorTableItem(sColorTable), false);
  561.                                 ColorStart := sColorStart;
  562.                                 ColorEnd := sColorEnd;
  563.                                 LutMode := Pseudocolor;
  564.                                 if sInvertedTable then
  565.                                     InvertPalette;
  566.                                 UpdateLut;
  567.                             end;
  568.                         if sVersion >= 144 then begin
  569.                                 HalftoneFrequency := sHalftoneFrequency;
  570.                                 HalftoneAngle := sHalftoneAngle;
  571.                                 HalftoneDotFunction := sHalftoneDotFunction;
  572.                             end;
  573.                     end;
  574.                 GetKernelsWorkingDir(settings);
  575.                 GetDefaultWorkingDir(settings);
  576.                 UpdateFitEllipse;
  577.             end; {with settings, info^}
  578.         case info^.LUTMode of
  579.             PseudoColor, ColorLut, CustomGrayscale: 
  580.                 UpdateLUT;
  581.             OldAppleDefault: 
  582.                 ok := LoadCLUTResource(AppleDefaultCLUT);
  583.             otherwise
  584.         end;
  585.         if nExtraColors > 0 then
  586.             RedrawLUTWindow;
  587.         if InvertPixelValues then
  588.             InvertGrayLevels;
  589.     end;
  590.  
  591.  
  592.     procedure MakePatterns;
  593. {Creates the patterns used to create the "marching ants". Thanks to}
  594. { Seth Snyder on CompuServe for the example.}
  595.         var
  596.             i, j: Integer;
  597.     begin
  598.         j := 0;
  599.         for i := 0 to 7 do begin
  600.                 pat[i][(j + 0) mod 8] := $1F;
  601.                 pat[i][(j + 1) mod 8] := $3E;
  602.                 pat[i][(j + 2) mod 8] := $7C;
  603.                 pat[i][(j + 3) mod 8] := $F8;
  604.                 pat[i][(j + 4) mod 8] := $F1;
  605.                 pat[i][(j + 5) mod 8] := $E3;
  606.                 pat[i][(j + 6) mod 8] := $C7;
  607.                 pat[i][(j + 7) mod 8] := $8F;
  608.                 j := j + 1;
  609.             end;
  610.         PatIndex := 0;
  611.     end;
  612.  
  613.  
  614.     procedure InitExtraColors;
  615.         var
  616.             i, j, ctop, cbottom, entry: integer;
  617.             tRect: rect;
  618.     begin
  619.         with ExtraColors[1] do begin
  620.                 red := -1;
  621.                 green := 0;
  622.                 blue := 0;
  623.             end;
  624.         with ExtraColors[2] do begin
  625.                 red := 0;
  626.                 green := -1;
  627.                 blue := 0;
  628.             end;
  629.         with ExtraColors[3] do begin
  630.                 red := 0;
  631.                 green := 0;
  632.                 blue := -1;
  633.             end;
  634.         with ExtraColors[4] do begin
  635.                 red := -1;
  636.                 green := -1;
  637.                 blue := 0;
  638.             end;
  639.         with ExtraColors[5] do begin
  640.                 red := 0;
  641.                 green := -1;
  642.                 blue := -1;
  643.             end;
  644.         with ExtraColors[6] do begin
  645.                 red := -1;
  646.                 green := 0;
  647.                 blue := -1;
  648.             end;
  649.         ctop := 256;
  650.         cbottom := ctop + ExtraColorsHeight;
  651.         for i := 1 to MaxExtraPlus2 do begin
  652.                 SetRect(tRect, 0, ctop, cwidth, cbottom);
  653.                 ExtraColorsRect[i] := tRect;
  654.                 ctop := ctop + ExtraColorsHeight;
  655.                 cbottom := cbottom + ExtraColorsHeight;
  656.             end;
  657.         ExtraColorsEntry[1] := WhiteIndex;
  658.         ExtraColorsEntry[2] := BlackIndex;
  659.         entry := FirstExtraColorsEntry;
  660.         j := 3;
  661.         for i := 1 to MaxExtraColors do begin
  662.                 ExtraColorsEntry[j] := entry;
  663.                 j := j + 1;
  664.                 Entry := Entry + 1;
  665.             end;
  666.     end;
  667.  
  668.  
  669.     function GetSlotBase (id: integer): LongInt;
  670.   {Returns the slot base address of the NuBus card with the specified id. The address}
  671.   {returned is in the form $Fss00000, which is valid in both 24 and 32-bit modes.}
  672.   {Returns 0 if a card with the given id is not found.}
  673.         type
  674.             SPRAMRecord = packed record
  675.                     BoardId: integer;
  676.                     VenderUse: packed array[1..6] of SignedByte;
  677.                 end;
  678.         var
  679.             SlotBlock: SpBlock;
  680.             sparm: SPRAMRecord;
  681.             SparmAddr: LongInt;
  682.             i: integer;
  683.             err: OSErr;
  684.     begin
  685.         with SlotBlock do begin
  686.                 SparmAddr := LongInt(@sparm);
  687.                 spResult := SparmAddr;
  688.                 for i := 9 to 15 do begin
  689.                         spSlot := i;
  690.                         err := sReadPRAMRec(@SlotBlock);
  691.                         if sparm.BoardID = id then begin
  692.                                 GetSlotBase := bor($F0000000, spSlot * $100000 + spSlot * $1000000);
  693.                                 exit(GetSlotBase)
  694.                             end;
  695.                     end;
  696.                 GetSlotBase := 0;
  697.             end;
  698.     end;
  699.  
  700.  
  701.     procedure SetupQCPort;
  702. {So we can use CopyBits, this routine sets up a color graf port that}
  703. {uses the memory on the QuickCapture board as the PixMap.}
  704.         const
  705.             baseAddr32 = 4;
  706.         var
  707.             tPort: GrafPtr;
  708.             trect: rect;
  709.     begin
  710.         GetPort(tPort);
  711.         new(qcPort);
  712.         OpenCPort(qcPort);
  713.         SetRect(trect, 0, 0, qcwidth, qcheight);
  714.         with qcPort^ do begin
  715.                 with PortPixMap^^ do begin
  716.                         BaseAddr := ptr(DTSlotBase);
  717.                         bounds := trect;
  718.                         RowBytes := BitOr(qcRowBytes, $8000);
  719.                         pmVersion := baseAddr32; {Needed for 8*24 GC card. See TN 275.}
  720.                     end;
  721.                 PortRect := trect;
  722.                 RectRgn(visRgn, trect);
  723.             end;
  724.         SetPort(tPort);
  725.         SetPalette(WindowPtr(qcPort), ExplicitPalette, false);
  726.     end;
  727.  
  728.  
  729.     procedure LookForFrameGrabbers;
  730.         const
  731.             ControlRegOffset = $80000;
  732.             ChannelRegOffset = $80004;
  733.             DT2255id = $11A;
  734.             Scion1000id = $14B;
  735.             Scion1200id = $222;
  736.             PalBufferSize = 393216; {768 x 512}
  737.         var
  738.             err: OSErr;
  739.             tPort: GrafPtr;
  740.             SlotBase: LongInt;
  741.             OptionKeyIsDown: boolean;
  742.     begin
  743.         OptionKeyIsDown := OptionKeyDown;
  744.         FrameGrabber := NoFrameGrabber;
  745.         qcPort := nil;
  746.         SlotBase := GetSlotBase(Scion1000id);
  747.         if (SlotBase <> 0) and not OptionKeyIsDown then begin
  748.                 FrameGrabber := Scion;
  749.                 ScionSlotBase := SlotBase;
  750.                 exit(LookForFrameGrabbers);
  751.             end;
  752.         SlotBase := GetSlotBase(Scion1200id);
  753.         if (SlotBase <> 0) and not OptionKeyIsDown then begin
  754.                 FrameGrabber := Scion;
  755.                 ScionSlotBase := SlotBase;
  756.                 exit(LookForFrameGrabbers);
  757.             end;
  758.         SlotBase := GetSlotBase(DT2255id);
  759.         if SlotBase <> 0 then begin
  760.                 FrameGrabber := QuickCapture;
  761.                 DTSlotBase := SlotBase
  762.             end;
  763.         qcWidth := 640;
  764.         qcHeight := 480;
  765.         if FrameGrabber = QuickCapture then begin
  766.                 ControlReg := ptr(DTSlotBase + ControlRegOffset);
  767.                 ChannelReg := ptr(DTSlotBase + ControlRegOffset + 4);
  768.                 if band(ChannelReg^, 8) = 8 then begin {Check for 50Hz(PAL) card}
  769.                         qcWidth := 768;
  770.                         qcHeight := 512;
  771.                         if BufferSize < PalBufferSize then
  772.                             BufferSize := PalBufferSize;
  773.                     end;
  774.                 SetupQCPort;
  775.                 ResetQuickCapture;
  776.             end;
  777.     end;
  778.  
  779.  
  780.     procedure CheckBits;
  781.         const
  782.             QD32Trap = $AB03;
  783.             UnimplementedTrap = $A89F;
  784.         var
  785.             MainDevice: GDHandle;
  786.             ScreenPixMap: PixMapHandle;
  787.             myEnvRec: SysEnvRec;
  788.             err: OSErr;
  789.     begin
  790.         err := SysEnvirons(1, myEnvRec);
  791.         if err <> envNotPresent then
  792.             with MyEnvRec do begin
  793.                     if not HasColorQD then begin
  794.                             PutMessage('Sorry, Image requires a Macintosh with Color QuickDraw.');
  795.                             ExitToShell;
  796.                         end;
  797.                     if not HasFPU and UsingFPU then begin
  798.                             PutMessage('This version of Image requires a floating-point coprocessor or the PseudoFPU INIT.');
  799.                             ExitToShell;
  800.                         end;
  801.                     OldSystem := systemVersion < $0605;
  802.                     System7 := systemVersion >= $0700;
  803.                     SystemRefnum := sysVRefNum;
  804.                 end;
  805.         Has32BitQuickDraw := nGetTrapAddress(QD32Trap, ToolTrap) <> nGetTrapAddress(UnimplementedTrap, ToolTrap);
  806.         MainDevice := GetMainDevice;
  807.         if MainDevice^^.gdPmap^^.PixelSize <> 8 then begin
  808.                 PutMessage('To run Image, the main monitor(the one with the menu bar) must be set to 256 colors or 256 gray levels.');
  809.                 ExitToShell;
  810.             end;
  811.         ScreenPixMap := MainDevice^^.gdPMap;
  812.         ScreenRowBytes := BitAnd(ScreenPixMap^^.rowBytes, $1fff);
  813.         ScreenBase := ScreenPixMap^^.baseAddr;
  814.     end;
  815.  
  816.  
  817.     procedure SetupMenus;
  818.         var
  819.             i: integer;
  820.     begin
  821.         AppleMenuH := GetMenu(AppleMenu);
  822.         InsertMenu(AppleMenuH, 0);
  823.         FileMenuH := GetMenu(FileMenu);
  824.         InsertMenu(FileMenuH, 0);
  825.         EditMenuH := GetMenu(EditMenu);
  826.         InsertMenu(EditMenuH, 0);
  827.         OptionsMenuH := GetMenu(OptionsMenu);
  828.         InsertMenu(OptionsMenuH, 0);
  829.         EnhanceMenuH := GetMenu(EnhanceMenu);
  830.         InsertMenu(EnhanceMenuH, 0);
  831.         AnalyzemenuH := GetMenu(AnalyzeMenu);
  832.         InsertMenu(AnalyzemenuH, 0);
  833.         SpecialMenuH := GetMenu(SpecialMenu);
  834.         InsertMenu(SpecialMenuH, 0);
  835.         StacksMenuH := GetMenu(StacksMenu);
  836.         InsertMenu(StacksMenuH, 0);
  837.         WindowsMenuH := GetMenu(WindowsMenu);
  838.         InsertMenu(WindowsMenuH, 0);
  839.  
  840.         FontMenuH := GetMenu(FontMenu);
  841.         InsertMenu(FontMenuH, -1);
  842.         SizeMenuH := GetMenu(SizeMenu);
  843.         InsertMenu(SizeMenuH, -1);
  844.         StyleMenuH := GetMenu(StyleMenu);
  845.         InsertMenu(StyleMenuH, -1);
  846.         BinaryMenuH := GetMenu(BinaryMenu);
  847.         InsertMenu(BinaryMenuH, -1);
  848.         ArithmeticMenuH := GetMenu(ArithmeticMenu);
  849.         InsertMenu(ArithmeticMenuH, -1);
  850.         BackgroundMenuH := GetMenu(BackgroundMenu);
  851.         InsertMenu(BackgroundMenuH, -1);
  852.         SortPaletteMenuH := GetMenu(SortPaletteMenu);
  853.         InsertMenu(SortPaletteMenuH, -1);
  854.         PropagateMenuH := GetMenu(PropagateMenu);
  855.         InsertMenu(PropagateMenuH, -1);
  856.         ColorTablesMenuH := GetMenu(ColorTablesMenu);
  857.         InsertMenu(ColorTablesMenuH, -1);
  858.  
  859.         TransferModeMenuH := GetMenu(TransferModeMenu);
  860.         InsertMenu(TransferModeMenuH, -1);
  861.  
  862.         LineToolMenuH := GetMenu(LineToolMenu);
  863.         InsertMenu(LineToolMenuH, -1);
  864.  
  865.         DrawMenuBar;
  866.         AddResMenu(AppleMenuH, 'DRVR');
  867.         AddResMenu(FontMenuH, 'FONT');
  868.         NumFontItems := CountMItems(FontMenuH);
  869.     end;
  870.  
  871.  
  872.     procedure FindMonitors;
  873. {Generate a list of monitors so we can update the color tables of multiple monitors.}
  874. {This wouldn't be necessary if we were using the Palette Manager.}
  875.         var
  876.             nextDevice: GDHandle;
  877.     begin
  878.         nMonitors := 0;
  879.         nextDevice := GetDeviceList;
  880.         while nextDevice <> nil do begin
  881.                 if TestDeviceAttribute(nextDevice, screenDevice) and TestDeviceAttribute(nextDevice, screenActive) then
  882.                     if nextDevice^^.gdPmap^^.PixelSize = 8 then begin
  883.                             nMonitors := nMonitors + 1;
  884.                             Monitors[nMonitors] := nextDevice;
  885.                         end;
  886.                 nextDevice := GetNextDevice(nextDevice);
  887.             end; {while}
  888.     end;
  889.  
  890.  
  891.     procedure Init;
  892.         var
  893.             i: integer;
  894.             p: SyspPtr;
  895.             mbhp: ^integer;
  896.             str: str255;
  897.             err: OSErr;
  898.     begin
  899.         SetApplLimit(ptr(LongInt(GetApplLimit) - StackSize));
  900.         MaxApplZone;
  901.         InitGraf(@ThePort);
  902.         InitFonts;
  903.         InitWindows;
  904.         InitCursor;
  905.   {PLHeapInit(100000,5000,Nil,true,true)-Needed for MPW}
  906.         TEInit;
  907.         InitDialogs(@SysResume);
  908.         CheckBits;
  909.         FindMonitors;
  910.         new(ScreenPort);
  911.         OpenPort(ScreenPort);
  912.         NoInfo := @NoInfoRec;
  913.         Info := NoInfo;
  914.         ValuesWindow := nil;
  915.         with BlackRGB do begin
  916.                 red := 0;
  917.                 blue := 0;
  918.                 green := 0;
  919.             end;
  920.         with WhiteRGB do begin
  921.                 red := -1;
  922.                 blue := -1;
  923.                 green := -1;
  924.             end;
  925.         with NoInfo^ do begin
  926.                 nlines := 0;
  927.                 PixelsPerLine := 0;
  928.                 ImageSize := 0;
  929.                 PixMapSize := 0;
  930.                 PicBaseAddr := nil;
  931.                 PicBaseHandle := nil;
  932.                 osPort := nil;
  933.                 RoiShowing := false;
  934.                 RoiType := NoRoi;
  935.                 RoiRect := SrcRect;
  936.                 roiRgn := NewRgn;
  937.                 title := 'NoInfo';
  938.                 Magnification := 1.0;
  939.                 PictureType := NullPicture;
  940.                 wptr := nil;
  941.                 Changes := false;
  942.                 BytesPerRow := 0;
  943.                 SetRect(SrcRect, 0, 0, 0, 0);
  944.                 PicRect := SrcRect;
  945.                 wrect := SrcRect;
  946.                 initwrect := wrect;
  947.                 savewrect := wrect;
  948.                 SaveSrcRect := SrcRect;
  949.                 SaveMagnification := magnification;
  950.                 savehloc := 0;
  951.                 savevloc := 0;
  952.                 ScaleToFitWindow := false;
  953.                 nColors := 256;
  954.                 ColorStart := 0;
  955.                 ColorEnd := 255;
  956.                 FillColor1 := BlackRGB;
  957.                 FillColor2 := BlackRGB;
  958.                 LUTMode := GrayScale;
  959.                 ColorTable := CustomTable;
  960.                 InvertedColorTable := false;
  961.                 units := '  ';
  962.                 FullUnits := 'Pixel';
  963.                 UnitsID := pixels;
  964.                 RawSpatialScale := 0.0;
  965.                 ScaleMagnification := 1.0;
  966.                 PixelAspectRatio := 1.0;
  967.                 xSpatialScale := RawSpatialScale * ScaleMagnification;
  968.                 ySpatialScale := xSpatialScale / PixelAspectRatio;
  969.                 SpatiallyCalibrated := false;
  970.                 UnitsPerCM := 0.0;
  971.                 UnitOfMeasure := '';
  972.                 PicNum := 1;
  973.                 HeaderOffset := -1;
  974.                 ImageDataOffset := -1;
  975.                 ColorMapOffset := -1;
  976.                 for i := 0 to 255 do
  977.                     ctable[i].value := 0;
  978.                 Fit := Poly3;
  979.                 DensityCalibrated := false;
  980.                 ZeroClip := false;
  981.                 nCoefficients := 0;
  982.                 for i := 1 to 6 do
  983.                     Coefficient[i] := 0.0;
  984.                 BinaryPic := false;
  985.                 WindowState := NormalWindow;
  986.                 FileDepth := EightBits;
  987.                 Revertable := false;
  988.                 uLength := 0.0;
  989.                 cLength := 0.0;
  990.                 LX1 := -1.0;
  991.                 LY1 := -1.0;
  992.                 LX2 := -1.0;
  993.                 LY2 := -1.0;
  994.                 IdentityFunction := false;
  995.                 StackInfo := nil;
  996.             end;
  997.         ExplicitPalette := NewPalette(256, nil, pmExplicit, 0);
  998.         new(CScreenPort);
  999.         OpenCPort(CScreenPort);
  1000.         SetPalette(WindowPtr(CScreenPort), ExplicitPalette, false);
  1001.         finished := false;
  1002.         FlushEvents(EveryEvent, 0);
  1003.         for i := 1 to 10 do
  1004.             MoreMasters;
  1005.         mbhp := pointer(MBarHeight);
  1006.         MenuBarHeight := mbhp^;
  1007.         SetRect(trect, tleft, ttop, tleft + twidth, ttop + theight);
  1008.         ToolWindow := NewCWindow(nil, trect, 'Tools', true, NoGrowDocProc, nil, false, 0);
  1009.         SetPalette(ToolWindow, ExplicitPalette, false);
  1010.         WindowPeek(ToolWindow)^.WindowKind := ToolKind;
  1011.         BringToFront(ToolWindow);
  1012.         ScreenWidth := ScreenBits.Bounds.right;
  1013.         ScreenHeight := ScreenBits.Bounds.bottom;
  1014.         SliceStart := 100;
  1015.         SliceEnd := 150;
  1016.         with SliceColor do begin
  1017.                 red := -1;
  1018.                 green := 0;
  1019.                 blue := 0;
  1020.             end;
  1021.         DensitySlicing := false;
  1022.         nExtraColors := 0;
  1023.         GrayMapReady := false;
  1024.         ResetGrayMap;   {LUT must be setup before InitMenus}
  1025.         InitMenus;
  1026.         SetRect(gmrect, gmleft, gmtop, gmleft + gmwidth, gmtop + gmheight);
  1027.         SetRect(gmSlide1, gmrectleft, gmrectbottom + gmSlide1Offset, gmrectleft + gmSlideWidth, gmrectbottom + gmSlide1Offset + gmSlideHeight);
  1028.         gmSlide1i := gmSlide1;
  1029.         InsetRect(gmSlide1i, 1, 1);
  1030.         SetRect(gmSlide2, gmrectleft, gmrectbottom + gmSlide2Offset, gmrectleft + gmSlideWidth, gmrectbottom + gmSlide2Offset + gmSlideHeight);
  1031.         gmSlide2i := gmSlide2;
  1032.         InsetRect(gmSlide2i, 1, 1);
  1033.         SetRect(gmIcon1, gmIcon1left, gmrectbottom + gmIconOffset, gmIcon1left + gmIconWidth, gmrectbottom + gmIconOffset + gmIconHeight);
  1034.         SetRect(gmIcon2, gmIcon2left, gmrectbottom + gmIconOffset, gmIcon2left + gmIconWidth, gmrectbottom + gmIconOffset + gmIconHeight);
  1035.         MapWindow := NewWindow(nil, gmrect, 'Map', true, NoGrowDocProc, nil, false, 0);
  1036.         WindowPeek(MapWindow)^.WindowKind := MapKind;
  1037.         SetRect(MapRect, gmRectLeft, gmRectTop, gmRectRight, gmRectBottom);
  1038.         MapRect2 := MapRect;
  1039.         InsetRect(MapRect2, -2, -2);
  1040.         cheight := 256 + (2 + nExtraColors) * ExtraColorsHeight;
  1041.         SetRect(crect, cleft, ctop, cleft + cwidth, ctop + cheight);
  1042.         LUTWindow := NewCWindow(nil, crect, 'LUT', true, NoGrowDocProc, nil, false, 0);
  1043.         SetPalette(LUTWindow, ExplicitPalette, false);
  1044.         WindowPeek(LUTWindow)^.WindowKind := LUTKind;
  1045.         rleft := 2;
  1046.         if ScreenHeight > 480 then
  1047.             rtop := ScreenHeight - rheight - 5
  1048.         else
  1049.             rtop := 358;
  1050.         SetRect(trect, rleft, rtop, rleft + rwidth, rtop + rheight);
  1051.         ValuesWindow := NewWindow(nil, trect, 'Values', true, NoGrowDocProc, nil, false, 0);
  1052.         BringToFront(ValuesWindow);
  1053.         WindowPeek(ValuesWindow)^.WindowKind := ValuesKind;
  1054.         BuggyWatch := GetCursor(WatchCursor);
  1055.         InitTools;
  1056.         MakeCursors;
  1057.         nPics := 0;
  1058.         HistoWindow := nil;
  1059.         PlotWindow := nil;
  1060.         IsInsertionPoint := false;
  1061.         MaskRgn := NewRgn;
  1062.         PlotPICT := nil;
  1063.         AutoscalePlots := true;
  1064.         InvertPlots := false;
  1065.         LinePlot := true;
  1066.         DrawPlotLabels := true;
  1067.         FixedSizePlot := false;
  1068.         ProfilePlotMin := 0;
  1069.         ProfilePlotMax := 255;
  1070.         ProfilePlotWidth := 300;
  1071.         ProfilePlotHeight := 150;
  1072.         AirbrushDiameter := 32;
  1073.         AirbrushRadius := 16;
  1074.         AirbrushRadius2 := 256;
  1075.         BrushWidth := 14;
  1076.         BrushHeight := 14;
  1077.         CurrentUndoSize := 0;
  1078.         p := GetSyspPtr;
  1079.         BlinkTime := BitAnd($000F, p^.volclik) * 4;
  1080.         MakePatterns;
  1081.         info^.LUTMode := GrayScale;
  1082.         PicLeftBase := twidth + cwidth + 10;
  1083.         PicTopBase := MenuBarHeight + 20;
  1084.         PicLeft := PicLeftBase;
  1085.         PicTop := PicTopBase;
  1086.         CurrentFontID := Helvetica;
  1087.         CurrentStyle := []; {plain}
  1088.         CurrentSize := 12;
  1089.         TextJust := teJustLeft;
  1090.         TextBack := NoBack;
  1091.         MouseState := NotInRoi;
  1092.         WhatsOnClip := Nothing;
  1093.         InitExtraColors;
  1094.         OldScrapCount := GetScrapCount;
  1095.         ClipboardConverted := false;
  1096.         BufferSize := DefaultBufferSize;
  1097.         LookForFrameGrabbers;
  1098.         VideoChannel := 0;
  1099.         Digitizing := false;
  1100.         debugging := false;
  1101.         BlankFieldInfo := nil;
  1102.         QuickCaptureInfo := nil;
  1103.         ScionInfo := nil;
  1104.         InvertVideo := false;
  1105.         HighlightSaturatedPixels := false;
  1106.         PlotCount := 0;
  1107.         ClipTextInBuffer := false;
  1108.         TextBufP := TextBufPtr(NewPtr(SizeOf(TextBufType)));
  1109.         if TextBufP = nil then
  1110.             ExitToShell;
  1111.         MacrosP := MacrosPtr(NewPtr(SizeOf(MacrosRec)));
  1112.         if MacrosP = nil then
  1113.             ExitToShell;
  1114.         mCount := 0;
  1115.         mCount2 := 0;
  1116.         nPoints := 0;
  1117.         nLengths := 0;
  1118.         nAngles := 0;
  1119.         for i := 1 to MaxStandards do
  1120.             StandardValues[i] := BadReal;
  1121.         nStandards := 0;
  1122.         for i := 0 to 255 do
  1123.             cvalue[i] := i;
  1124.         WhatToUndo := NothingToUndo;
  1125.         WhatToCopy := NothingToCopy;
  1126.         PrintRecord := nil;
  1127.         printing := false;
  1128.         HalftoneFrequency := 53;
  1129.         HalftoneAngle := 45;
  1130.         HalftoneDotFunction := true;
  1131.         cr := chr(13);
  1132.         tab := chr(9);
  1133.         BackSpace := chr(8);
  1134.         eof := chr(4);
  1135.         measuring := false;
  1136.         measurements := [AreaM, MeanM];
  1137.         UpdateFitEllipse;
  1138.         nListColumns := 0;
  1139.         FramesToAverage := 16;
  1140.         NewPicWidth := 552;
  1141.         NewPicHeight := 436;
  1142.         RestoreUndoBuf := true;
  1143.         MaxScionWidth := 600;
  1144.         ThresholdToForeground := true;
  1145.         NonThresholdToBackground := true;
  1146.         SelectionMode := NewSelection;
  1147.         RoiMovementState := Unconstrained;
  1148.         PasteControl := nil;
  1149.         PasteTransferMode := SrcCopy;
  1150.         WhatToImport := ImportTIFF;
  1151.         ImportCustomWidth := 512;
  1152.         ImportCustomHeight := 512;
  1153.         ImportCustomOffset := 0;
  1154.         ImportCustomDepth := EightBits;
  1155.         ImportSwapBytes := false;
  1156.         ImportCalibrate := true;
  1157.         ImportAll := false;
  1158.         RoiNudged := false;
  1159.         ForegroundIndex := BlackIndex;
  1160.         BackgroundIndex := WhiteIndex;
  1161.         OpPending := false;
  1162.         RedoSelection := false;
  1163.         WandAutoMeasure := false;
  1164.         WandAdjustAreas := false;
  1165.         OptionKeyWasDown := false;
  1166.         BinaryIterations := 1;
  1167.         ScaleArithmetic := true;
  1168.         ValuesMessage := '';
  1169.         SaveAsWhat := asTIFF;
  1170.         ExportAsWhat := asRaw;
  1171.         AnalyzingParticles := false;
  1172.         RedirectSampling := false;
  1173.         MinParticleSize := 1;
  1174.         MaxParticleSize := 999999;
  1175.         LabelParticles := true;
  1176.         OutlineParticles := false;
  1177.         IgnoreParticlesTouchingEdge := false;
  1178.         IncludeHoles := false;
  1179.         SaveAllState := NoSaveAll;
  1180.         InvertYCoordinates := true;
  1181.         ContinuousHistogram := false;
  1182.         DrawLabels(' ', '', '');
  1183.         HistogramSliceStart := 0;
  1184.         HistogramSliceEnd := 255;
  1185.         RoiUpdateTime := 0;
  1186.         FieldWidth := 9;
  1187.         precision := 2;
  1188.         MeasurementToRedo := 0;
  1189.         nMacros := 0;
  1190.         macro := false;
  1191.         KernelsRefNum := 0;
  1192.         DefaultRefNum := 0;
  1193.         DefaultFileName := '';
  1194.         rsHScale := 1.0;
  1195.         rsVScale := 1.0;
  1196.         rsAngle := 0.0;
  1197.         rsMethod := NearestNeighbor;
  1198.         rsCreateNewWindow := true;
  1199.         rsInteractive := false;
  1200.         ImportAutoScale := true;
  1201.         ImportMin := 0.0;
  1202.         ImportMax := 255.0;
  1203.         InvertPixelValues := false;
  1204.         OscillatingMovies := false;
  1205.         DriverHalftoning := false;
  1206.         LivePasteMode := false;
  1207.         ShowCount := true;
  1208.         PasteControlLeft := ScreenWidth - pcwidth - 10;
  1209.         PasteControlTop := trunc(ScreenHeight * 0.2);
  1210.         MaxRegions := 200;
  1211.         ResultsLeft := 50;
  1212.         ResultsTop := 50;
  1213.         UnsavedResults := false;
  1214.         MajorLabel := 'Major';
  1215.         MinorLabel := 'Minor';
  1216.         User1Label := 'User 1';
  1217.         User2Label := 'User 2';
  1218.         ShowHeadings := false;
  1219.         MakingLOI := false;
  1220.         LOIType := Straight;
  1221.         MakingStack := false;
  1222.         FramesWanted := 20;
  1223.         ScaleConvolutions := true;
  1224.         FasterBackgroundSubtraction := true;
  1225.         BallRadius := 50;
  1226.         DelayTicks := 0;
  1227.         CmdPeriodToStop := 'Type cmd-''.'' to stop.';
  1228.         CommandKey := chr(17);
  1229.         BinaryCount := 4;
  1230.         BinaryThreshold := BinaryCount * 255;
  1231.         ClipboardColor := BlackRGB;
  1232.         InitAngle := 0;                                             {default is one full revolution of volume}
  1233.         TotalAngle := 360;
  1234.         AngleInc := 10;                                           {in ten-degree increments}
  1235.         TransparencyUpper := 254;                      {default has only value 255 transparent}
  1236.         TransparencyLower := 0;
  1237.         DepthCueSurf := 0;                                     {default has full depth-cueing for surface}
  1238.         DepthCueInt := 100;                                   {components and no depth-cueing elsewhere}
  1239.         SaveProjections := FALSE;                         {by default, do not save and close projections}
  1240.         AxisOfRotation := xAxis;
  1241.         MinProjSize := TRUE;                                {by default, make all windows just big enough}
  1242.         ProjectionMethod := NearestPoint;
  1243.         MeterWindow := nil;
  1244.         nCoordinates := 0;
  1245.         SwitchLUTOnSuspend := false;
  1246.         SumFrames := false;
  1247.         ExternalTrigger := false;
  1248.         BlindMovieCapture := false;
  1249.     end;
  1250.  
  1251.  
  1252. end.