unit Globals; {Global declarations for NIH Image program.} interface uses QuickDraw, Palettes, PrintTraps; const Version = 155; UsingFPU = true; {If true, select 68881/68882 in Compile Options dialog box.} AppleMenu = 128; FileMenu = 129; NewItem = 1; OpenItem = 2; ImportItem = 3; CloseItem = 5; SaveItem = 6; SaveAsItem = 7; ExportItem = 8; RecordPreferencesItem = 10; RevertItem = 11; DuplicateItem = 12; GetInfoItem = 13; AcquireItem = 15; PlugInExportItem = 16; SetHalftoneItem = 18; PageSetupItem = 19; PrintItem = 20; QuitItem = 22; AcquireMenu = 42; {Sub Menu} ExportMenu = 44; {Sub Menu} EditMenu = 130; UndoItem = 1; CutItem = 3; CopyItem = 4; PasteItem = 5; ClearItem = 6; FillItem = 8; InvertItem = 9; DrawBoundaryItem = 10; DrawScaleItem = 11; SelectAllItem = 13; ScaleAndRotateItem = 14; RotateLeftItem = 16; RotateRightItem = 17; FlipVerticalItem = 18; FlipHorizontalItem = 19; UnzoomItem = 21; ShowClipboardItem = 22; OptionsMenu = 131; GrayscaleItem = 1; ColorTablesItem = 2; LutOptionsItem = 3; PreferencesItem = 9; PlotOptionsItem = 10; ScaleToFitItem = 11; ThresholdItem = 12; SliceItem = 13; PropagateItem = 14; FontMenu = 32; {Sub Menu} SizeMenu = 33; {Sub Menu} StyleMenu = 34; {Sub Menu} LeftItem = 8; CenterItem = 9; RightItem = 10; NoBackgroundItem = 12; WithBackgroundItem = 13; ColorTablesMenu = 41; {Sub Menu} SystemPaletteItem = 1; Pseudo20Item = 2; Pseudo32Item = 3; RainbowItem = 4; Fire1Item = 5; Fire2Item = 6; IceItem = 7; GraysItem = 8; SpectrumItem = 9; PropagateMenu = 38; {Sub Menu} LUTItem = 1; SpatialItem = 2; DensityItem = 3; AllItem = 4; EnhanceMenu = 132; SmoothItem = 1; SharpenItem = 2; ShadowItem = 3; EdgeDetectItem = 4; ReduceNoiseItem = 5; DitherItem = 6; ConvolveItem = 7; FilterItem = 8; BinaryItem = 10; ConstMathItem = 11; ImageMathItem = 12; BackgroundItem = 13; ApplyItem = 14; EnhanceItem = 15; EqualizeItem = 16; FixColorsItem = 17; FilterMenu = 43; {Sub Menu} BinaryMenu = 35; {Sub Menu} MakeBinaryItem = 1; ErosionItem = 3; DilationItem = 4; OpeningItem = 5; ClosingItem = 6; SetCountItem = 7; IterationsItem = 8; OutlineItem = 10; SkeletonizeItem = 11; ArithmeticMenu = 37; {Sub Menu} AddItem = 1; SubtractItem = 2; MultiplyItem = 3; DivideItem = 4; LogItem = 5; BackgroundMenu = 40; {Sub Menu} HorizontalItem = 1; VerticalItem = 2; Sub2DItem = 3; RemoveStreaksItem = 4; FasterItem = 6; RadiusItem = 7; AnalyzeMenu = 133; MeasureItem = 1; AnalyzeItem = 2; ShowItem = 3; HistogramItem = 4; PlotItem = 5; PlotSurfaceItem = 6; OptionsItem = 7; SetScaleItem = 9; CalibrateItem = 10; RedoItem = 11; DeleteItem = 12; ResetItem = 13; RestoreItem = 14; MarkItem = 15; SpecialMenu = 140; StartItem = 1; AverageItem = 2; SaveBlankFieldItem = 3; VideoControlItem = 4; PhotoModeItem = 5; LoadMacrosItem = 7; FirstMacroItem = 9; StacksMenu = 141; StackFromWindowsItem = 1; WindowsFromStackItem = 2; AddSliceItem = 3; DeleteSliceItem = 4; NextSliceItem = 5; PreviousSliceItem = 6; MakeMovieItem = 8; CaptureFramesItem = 9; AnimateItem = 10; AverageSlicesItem = 11; MakeMontageItem = 12; CaptureColorItem = 14; RGBToColorItem = 15; ColorToRGBItem = 16; RGBToHSVItem = 17; RegisterItem = 19; ProjectItem = 20; ResliceItem = 21; ResliceOptionsItem = 22; WindowsMenu = 138; NextImageItem = 1; StackImagesItem = 2; CascadeImagesItem = 3; PasteControlItem = 4; SelectToolsItem = 6; SelectGrayMapItem = 7; SelectLutItem = 8; SelectInfoItem = 9; SelectHistogramItem = 10; SelectPlotItem = 11; SelectResultsItem = 12; UserMenu = 139; FirstMacroMenu = 142; {menus created as directed by macro name strings in macro file} LastMacroMenu = 160; TransferModeMenu = 200; {Popup Menu in Paste Control window} CopyModeItem = 1; AndItem = 2; OrItem = 3; XorItem = 4; ReplaceItem = 5; BlendItem = 6; LineToolMenu = 201; StraightItem = 1; SegmentedItem = 2; FreehandItem = 3; ImageMathOpsMenu = 202; ImageListMenu = 203; UnitsMenu = 204; InvertID = 1; HighLightID = 2; OscillatingID = 3; TriggerID = 4; BlindID = 5; FirstChannelID = 7; OffsetID = 13; GainID = 14; ResetID = 15; OffsetUpID = 16; OffsetDownID = 17; GainUpID = 18; GainDownID = 19; SyncID = 20; MinFree = 150000; HeaderSize = 512; TiffDirSize = 256; MaxLine = 4096; tleft = 36; ttop = 40; twidth = 44; tmiddle = 22; theight = 277; gmleft = 2; gmtop = 338; gmwidth = 78; gmheight = 118; gmRectLeft = 7; gmRectTop = 6; gmRectRight = 71; gmRectBottom = 70; gmSlideWidth = 68; gmSlideHeight = 7; gmSlide1Offset = 8; gmSlide2Offset = 19; gmIconWidth = 17; gmIconHeight = 14; gmIconOffset = 31; gmIcon1Left = 17; gmIcon2Left = 46; cleft = 2; ctop = 40; cwidth = 30; rwidth = 200; rheight = 225; hleft = 220; hwidth = 256; hheight = 120; pcwidth = 186; pcheight = 85; MaxPseudoColors = 32; MaxPseudoColorsLessOne = 31; PicKind = 88; HistoKind = 89; ProfilePlotKind = 90; LUTKind = 91; MapKind = 92; ToolKind = 93; InfoKind = 94; CalibrationPlotKind = 95; PasteControlKind = 96; ResultsKind = 97; TextKind = 98; UserKind = 99; IOErrorID = 400; AboutID = 256; VersItem = 2; MemItem = 3; StackSize = 40000; ToolFont = 249; {Bits 7-14 of font resource ID(31884) } WindowsMenuItems = 13; {Items in Windows menu before images - nTextWindows} WhiteIndex = 0; BlackIndex = 255; OvalSize = 15; LinesLeft = 13; LinesRight = 40; nLinetypes = 6; CheckMarkChar = 65; TxPlain = 1; TxBold = 2; TxItalic = 3; TxUnderLine = 4; TxOutLine = 5; TxShadow = 6; FileID8 = 'IPICIMAG'; DefaultBufferSize = 307200; {Enough for 640x480 image} PickerCursorID = 111; LUTCursorID = 112; gmCursorID = 113; GrabberCursorID = 114; PencilCursorID = 115; CrossCursorID = 117; CrossCursorPlusID = 118; CrossCursorMinusID = 119; BucketCursorID = 120; GlassCursorPlusID = 121; GlassCursorMinusID = 122; WandCursorID = 123; WandPlusCursorID = 124; WandMinusCursorID = 125; TextCursorID = 126; EraserCursorID = 127; SprayCursorID = 128; BrushCursorID = 129; FirstAnimatedWatchID = 130; AppleDefaultCLUT = 8; SpectrumCLUT = 200; KlutzID = 200; PixelPaintID = 999; {Used for PixelPaint and Canvas CLUTs} GhostWindow = $A84; GrayRgnGlobal = $9EE; MBarHeight = $BAA; MaxPics = 250; FirstExtraColorsEntry = 1; MaxExtraColors = 6; MaxExtraPlus2 = 8; ExtraColorsHeight = 10; MyMaxLong = 2000000000; MaxTextBufSize = 32700; MaxMaxRegions = 8000; MaxStandards = 20; BadReal = 808080.0; NoValue = -808080.0; TabSpacing = 12; MaxPolyVertices = 4000; pi = 3.1415926535898; InfoVStart = 11; InfoHStart = 4; {TIFF Constants} short = 3; long = 4; NewSubfileType = 254; ImageWidth = 256; ImageLength = 257; BitsPerSample = 258; Compression = 259; PhotoInterp = 262; StripOffsets = 273; SamplesPerPixel = 277; RowsPerStrip = 278; StripByteCount = 279; XResolution = 282; YResolution = 283; ResolutionUnit = 296; ColorMapTag = 320; ImageHdrTag = -22222; {43314} TiffFillerSize = 67; RoiHandleSize = 5; CancelResetID = 3; npcItems = 7; {Blend = 32;} {Transparent = 36;} LeftArrow = 28; RightArrow = 29; UpArrow = 30; DownArrow = 31; hPicOffset = 8; vPicOffset = 16; fgRowBytes = 1024; FunctionKey = 16; {MaxMacroSize = 15000;} MaxSymbols = 1000; {was 500, increased for UMX} MaxMacroStackSize = 200; {was 150} MaxMacros = 4094; {32768 / sizeof(MacroItemsRec) - 2} SymbolSize = 12; BlankSymbol = ' '; StackOverflow = 'Stack overflow'; MaxPicSize = 16383; ScrollBarWidth = 15; PrefsName = 'Image Prefs'; StraightChar = 97; SegmentedChar = 98; FreehandChar = 99; MaxSlices = 1000; HomeKey = 1; EndKey = 4; PageUp = 11; PageDown = 12; osEvt = 15; Pseudo20ID = 1001; Pseudo32ID = 1002; RainbowID = 1003; Fire1ID = 1004; Fire2ID = 1005; IceID = 1006; GraysID = 1007; MaxColor = 15000; MaxCoordinates = 10000; DefaultLG3DacLow = 50; {0.39V} DefaultLG3DacHigh = 150; {1.18V} MaxTextWindows = 100; {was 10} type UnsignedByte = 0..255; LineType = packed array[0..MaxLine] of UnsignedByte; LinePtr = ^LineType; rLineType = array[0..MaxLine] of real; rLinePtr = ^rLineType; RealLine = array[1..MaxLine] of real; ClutTable = packed array[0..255] of integer; ColorArray = packed array[0..MaxPseudoColorsLessOne] of byte; LutArray = packed array[0..255] of byte; PicType = (pdp11, NewPicture, normal, PictFile, Leftover, imported, FrameGrabberType, NullPicture, BlankField, TiffFile, InvertedTIFF, FourBitTIFF, ScionType, PicsFile); LUTModeType = (PseudoColor, OldAppleDefault, OldSpectrum, GrayScale, ColorLut, CustomGrayscale); ColorTableType = (CustomTable, AppleDefault, Pseudo20, Pseudo32, Rainbow, Fire1, Fire2, Ice, Grays, Spectrum); ExtraColorsArray = array[1..MaxExtraColors] of rgbColor; MyCSpecArray = array[0..255] of ColorSpec; CoefficientArray = array[1..6] of double; CurveFitType = (StraightLine, Poly2, Poly3, Poly4, Poly5, ExpoFit, PowerFit, LogFit, RodbardFit, SpareFit1, SpareFit2, UncalibratedOD); UnitsType = (Nanometers, Micrometers, Millimeters, Centimeters, Meters, Kilometers, Inches, Feet, Miles, Pixels, OtherUnits); UnitType = string[11]; FileDepthType = (EightBits, SixteenBitsUnsigned, SixteenBitsSigned); RoiTypeType = (PolygonRoi, RectRoi, OvalRoi, LineRoi, FreeLineRoi, SegLineRoi, NoRoi, FreehandRoi); PicHeader = record FileID: packed array[1..8] of char; {8 8} hnlines: integer; {2 10} hPixelsPerLine: integer; {2 12} hversion: integer; {2 14} hOldLutMode: LutModeType; {2 16} hOldnColors: integer; {2 18} hr, hg, hb: ColorArray; {96 114} hOldColorStart: integer; {2 116} hColorWidth: integer; {2 118} hExtraColors: ExtraColorsArray; {36 154} hnExtraColors: integer; {2 156} hForegroundIndex: integer; {2 158} hBackgroundIndex: integer; {2 160} hXSpatialScale: double; {8 168} Unused2: integer; {2 170} Unused3: integer; {2 172} hUnitsID: integer; {2 174} hp1x, hp1y, hp2x, hp2y: integer; {8 182} hfit: CurveFitType; {2 184} hnCoefficients: integer; {2 186} hCoeff: CoefficientArray; {48 234} hUM: string[15]; {16 250} UnusedBoolean: boolean; {1 251} hBinaryPic: boolean; {1 252} hSliceStart: integer; {2 254} hSliceEnd: integer; {2 256} hScaleMagnification: real; {4 260} hNSlices: integer; {2 262} hSliceSpacing: real; {4 266} hCurrentSlice: integer; {2 268} hLoopTime: real; {4 272} hPixelAspectRatio: real; {4 276} hColorStart: integer; {2 278} hColorEnd: integer; {2 280} hnColors: integer; {2 282} hFill1, hFill2: RGBColor; {12 294} hTable: ColorTableType; {1 295} hLutMode: LutModeType; {1 296} hInvertedTable: boolean; {1 297} hZeroClip: boolean; {1 298} hXUnit: string[11]; {12 310} UnusedBytes: packed array[1..202] of byte; end; StackInfoRec = record nSlices: integer; CurrentSlice: integer; PicBaseH: array[1..MaxSlices] of handle; SliceSpacing: real; {Pixels} LoopTime: real; end; StackInfoPtr = ^StackInfoRec; PaletteHeader = record pID: packed array[1..4] of char; {4 4} pVersion: integer; {2 6} pnColors: integer; {2 8} pColorStart: integer; {2 10} pColorEnd: integer; {2 12} pFill1: rgbColor; {6 18} pFill2: rgbColor; {6 24} pUnused: array[1..4] of integer; {8 32} end; RoiHeader = record rID: packed array[1..4] of char; {4 4} rVersion: integer; {2 6} rRoiType: RoiTypeType; {2 8} rRoiRect: rect; {8 16} rNCoordinates: integer; {2 18} rX1, rY1, rX2, rY2: real; {16 34} rLineWidth: integer; {2 36} rUnused: array[1..14] of integer; {28 64} end; PicInfo = record nlines, PixelsPerLine: integer; ImageSize: LongInt; BytesPerRow: integer; PicBaseAddr: ptr; PicBaseHandle: handle; osPort: cGrafPtr; {Offscreen Port} PicRect: rect; RoiRect: rect; roiRgn: rgnHandle; RoiType: RoiTypeType; SrcRect: rect; wrect: rect; initwrect: rect; savewrect, SaveSrcRect: rect; SaveMagnification: extended; savehloc, savevloc: integer; {Old window location in global coordinates} RoiShowing: boolean; title: string[31]; NewPic: boolean; Magnification: extended; vref: integer; PictureType: PicType; wptr: WindowPtr; PicNum, PidNum: integer; ScaleToFitWindow: boolean; Changes: boolean; RedLUT, GreenLUT, BlueLUT: LutArray; nColors: integer; ColorStart, ColorEnd, SaveColorStart, SaveColorEnd: LongInt; FillColor1, FillColor2, SaveFill1, SaveFill2: RGBColor; LUTMode: LUTModeType; ColorTable: ColorTableType; InvertedColorTable: boolean; cTable: MyCSpecArray; IdentityFunction: boolean; PixMapSize: LongInt; xSpatialScale, ySpatialScale, PixelAspectRatio: extended; xUnit: UnitType; {Someday there may be yUnit} UnitOfMeasure: string[15]; HeaderOffset, ImageDataOffset, ColorMapOffset: LongInt; Fit: CurveFitType; nCoefficients: integer; Coefficient: CoefficientArray; DensityCalibrated, SpatiallyCalibrated: boolean; ZeroClip: boolean; BinaryPic: boolean; WindowState: (NormalWindow, TiledSmall, TiledSmallScaled, TiledBig, TiledBigScaled); Revertable: boolean; LX1, LY1, LX2, LY2, LAngle: real; StackInfo: StackInfoPtr; Thresholding: boolean; iVersion: integer; DataType: FileDepthType; AbsoluteMin, AbsoluteMax, CurrentMin, CurrentMax: LongInt; LittleEndian: boolean; DataH: handle; end; InfoPtr = ^PicInfo; ToolType = (MagnifyingGlass, SelectionTool, Grabber, OvalSelectionTool, Pencil, PolygonTool, Eraser, FreehandTool, Brush, LineTool, ruler, LUTTool, PaintBucket, TextTool, PlotTool, SprayCanTool, Wand, PickerTool, AngleTool, CrossHairTool); OpType = (InvertOp, PaintOp, FrameOp, EraseOp, PasteOp, AddOp, SubtractOp, MultiplyOp, DivideOp); ObjectType = (lineObj, oval, SelectionOval, Rectangle, SelectionRect, BrushObj); FilterType = (WeightedAvg, UnweightedAvg, fsharpen, fshadow, EdgeDetect, ReduceNoise, dither, erosion, dilation, OutlineFilter, skeletonize); rhptr = ^RgnHandle; FlipRotateType = (RotateLeft, RotateRight, FlipVertical, FlipHorizontal); TextBackType = (NoBack, WithBack); HistogramType = array[0..255] of LongInt; str4 = packed array[1..4] of char; LookupTable = packed array[0..255] of UnsignedByte; TextBufType = packed array[1..MaxTextBufSize] of char; TextBufPtr = ^TextBufType; StandardsArray = array[1..MaxStandards] of extended; MeasurementTypes = (AreaM, MeanM, StdDevM, xyLocM, ModeM, LengthM, MajorAxisM, MinorAxisM, AngleM, IntDenM, MinMaxM, User1M, User2M); TiffHdr = record ByteOrder: packed array[1..2] of char; Version: integer; FirstIFDOffset: LongInt; end; TiffEntry = record TagField: integer; ftype: integer; length: LongInt; offset: LongInt; end; pcItemType = (pcPopupMenu, pcCheckBox, pcButton); WhatToImportType = (ImportTIFF, ImportMCID, ImportLUT, ImportText, ImportCustom); FateTable = array[0..255] of integer; SaveAsWhatType = (asTIFF, asPICT, asMacPaint, asPICS, AsPalette, AsOutline, AsRawData, SaveAsMCID); ExportAsWhatType = (AsRaw, asMCID, asText, AsLUT, asMeasurements, asPlotValues, asHistogramValues, asCoordinates); RealArray = array[0..MaxMaxRegions] of real; meanType = RealArray; sdType = RealArray; PixelCountType = array[0..MaxMaxRegions] of LongInt; AreaType = RealArray; modeType = RealArray; IntegratedDensityType = RealArray; idBackgroundType = RealArray; xcenterType = RealArray; ycenterType = RealArray; MajorAxisType = RealArray; MinorAxisType = RealArray; orientationType = RealArray; MinType = RealArray; MaxType = RealArray; plengthType = RealArray; User1Type = RealArray; User2Type = RealArray; meanPtr = ^meanType; sdPtr = ^sdType; PixelCountPtr = ^PixelCountType; AreaPtr = ^AreaType; modePtr = ^modeType; IntegratedDensityPtr = ^IntegratedDensityType; idBackgroundPtr = ^idBackgroundType; xcenterPtr = ^xcenterType; ycenterPtr = ^ycenterType; MajorAxisPtr = ^MajorAxisType; MinorAxisPtr = ^MinorAxisType; orientationPtr = ^orientationType; MinPtr = ^MinType; MaxPtr = ^MaxType; plengthPtr = ^plengthType; User1Ptr = ^User1Type; User2Ptr = ^User2Type; SyncModeType = (NormalSync, SeparateSync, SyncOnGreen); TokenType = (NullT, MacroT, NewLineT, beginT, endT, Identifier, UnknownIdentifier, DoneT, LeftParen, {} RightBracket, comma, colon, SemiColon, StringLiteral, NumericLiteral, VarT, IntegerT, RealT, BooleanT, CommandT,{} FunctionT, ArrayT, AssignOp, ForT, ToT, DoT, IfT, ThenT, ElseT, whileT, repeatT, untilT, Variable, PlusOp,{} MinusOp, MulOp, DivOp, eqOP, ltOp, gtOp, neOp, leOp, geOp, orOp, IntDivOp, modOp, andOp, NotOp, ProcedureT,{} ProcIdT, TrueT, FalseT, RightParen, LeftBracket, StringT, StringVariable, {} StringFunctionT, UserCommandT, UserFuncT, UserStrFuncT); CommandType = (InvertLUTC, UserCodeC, MoveWindowC, AutoThresholdC, SetExportC, SubtractBackgroundC,{} SetUser1C, SetUser2C, GetPlotDataC, PlotDataC, RequiresC, SetOptionsC, BufferC, GetSpacingC, SetSpacingC, {} PropagateLutC, PropagateDensityC, PropagateSpatialC, SetCountC, ShowMsgC, UpdateLutC, SetCounterC, RedLutC,{} GreenLutC, BlueLutC, SaveStateC, RestoreStateC, GetTimeC, SetScaleC, MakeLineC, PlotProfileC, ResliceC, CopyModeC,{} TriggerC, AverageFramesC, AddSliceC, DeleteSliceC, MakeStackC, GetSliceC, nSlicesC, SelectSliceC, ChooseSliceC, {} GetMouseC, SetMajorC, SetMinorC, CascadeC, rAreaC, rMeanC, rStdDevC, rAngleC, rXC, rYC, rLengthC, rMajorC, {} rMinorC, rMinC, rMaxC, rUser1C, rUser2C, UpdateResultsC, rCountC, HistogramC, ChangeC, ExportC, PicNumC,{} ScaleSelectionC, ScalingOptionsC, PutPixelC, ChoosePicC, WriteC, WritelnC,{} SetPrecisionC, SetParticleSizeC, AdjustC, IgnoreC,{} OutlineParticlesC, LabelC, IncludeC, AutoC, PlotXYZC, CalibratedC, cValueC, SameSizeC, GetColumnC, PutColumnC, {} GetRowC, PutRowC, ShowResultsC, SetWidthC, ScaleMathC, InvertYC, AndC, OrC, XorC, BlendC, ReplaceC, AddC, SubC, {} MulC, DivC, SetOptionC, GetResultsC, SetLabelsC, SetPlotScaleC, SetDimC, ColumnC, ChannelC, ShowPasteC, NullC,{} RotateRC, RotateLC, FlipVC, FlipHC, CopyC, SelectC, ClearC, FillC, InvertC, FrameC, PasteC, KillC, RestoreC, AnalyzeC,{} ConvolveC, NextC, MarkC, MeasureC, ThresholdC, ResetgmC, MakeBinC, DitherC, SmoothC, SharpenC, ShadowC, {} TraceC, ReduceC, SetSliceC, RedirectC, WaitC, ResetmC, UndoC, SetForeC, SetBackC, ScaleC, HistoC, EnhanceC, {} EqualizeC, ErodeC, DilateC, OutlineC, ThinC, AddConstC, MulConstC, RevertC, BeepC, NopC, MakeC, MakeOvalC, {} MoveC, InsetC, MoveToC, LineToC, DrawTextC, DrawNumC, SetFontC, SetFontSizeC, SetTextC, GetPicSizeC, PutMsgC, {} ExitC, GetRoiC, TruncC, RoundC, GetNumC, StartC, StopC, CaptureC, RandomC, MakeNewC, DrawScaleC, SetPaletteC, {} GetPixelC, ButtonC, oddC, absC, sqrtC, sinC, cosC, expC, lnC, arctanC, sqrC, OpenC, ImportC, SetImportC, SetMinMaxC,{} SetCustomC, nPicsC, SelectPicC, SetPicNameC, ApplyLutC, SetSizeC, SaveC, SaveAllC, SaveAsC, CopyResultsC, CloseC, {} DisposeC, DisposeAllC, DupC, GetInfoC, PrintC, GetLineC, xCoordinatesC, yCoordinatesC, nCoordinatesC, GetStringC, {} OpenSerialC, GetSerialC, PutSerialC, ChrC, OrdC, SetCursorC, TickCountC, ConcatC, SetVideoC, StringToNumC, AcquireC,{} UndoSizeC, ScionC, FilterC, PhotoModeC, RGBToIndexedC, SurfacePlotC, SelectWindowC, NewTextWindowC, CaptureColorC,{} GetThresholdC, AverageSlicesC, BitAndC, BitOrC, PidNumC, SortPaletteC, ProjectC, WindowTitleC, ScaleConvolutionsC,{} ImageMathC, PasteLiveC, PidExistsC, PosC, DeleteC, LengthC, GetScaleC, AutoOutlineC,{} LoadMacrosC, ConcatZFC); SymbolType = packed array[1..SymbolSize] of char; VarType = (IntVar, RealVar, BooleanVar, StringVar); SymTabRec = record Symbol: SymbolType; tType: TokenType; cType: CommandType; loc: LongInt; end; str255P = ^str255; str255H = ^str255P; StackRec = record SymbolTableIndex: integer; Value: extended; vType: VarType; StringH: str255H; end; MacrosRec = record {Macros: packed array[0..MaxMacroSize] of char;} SymbolTable: array[1..MaxSymbols] of SymTabRec; stack: array[1..MaxMacroStackSize] of StackRec; aLine: LineType; end; MacrosPtr = ^MacrosRec; MacroItemsRec = packed record MacroStart: Longint; MMitem: integer; MMenuID: 0..255; MacroKey: char; end; MacroItemsArray = array[0..MaxMacros] of MacroItemsRec; MacroItemsPtr = ^MacroItemsArray; MacroItemsHandle = ^MacroItemsPtr; rsMethodType = (Bilinear, NearestNeighbor); TiffColorMapType = array[1..3] of array[0..255] of integer; StackIFDType = record nEntries: integer; {2} TiffDir: array[1..6] of TiffEntry; {72} NextIFD: LongInt; {4} end; SettingsType = record sID: packed array[1..4] of char; sVersion: integer; sForegroundIndex, sBackgroundIndex: integer; sBrushHeight, sBrushWidth: integer; sSprayCanDiameter: integer; sLUTMode: LUTModeType; sOldColorStart: integer; sOldColorWidth: integer; sCurrentFontID: integer; sCurrentStyle: style; sCurrentSize: integer; sTextJust: integer; sTextBack: TextBackType; snExtraColors: integer; sExtraColors: ExtraColorsArray; sInvertVideo: boolean; sMeasurements: set of MeasurementTypes; sInvertPlots, sAutoScalePlots, sLinePlot, sDrawPlotLabels, sFixedSizePlot: boolean; sUnused1: packed array[1..12] of integer; sProfilePlotWidth, sProfilePlotHeight: integer; sFramesToAverage: integer; sNewPicWidth, sNewPicHeight: integer; sBufferSize: LongInt; sMaxScionWidth: integer; sThresholdToForeground, sNonThresholdToBackground: boolean; sVideoChannel: integer; sWhatToImport: WhatToImportType; sImportCustomWidth, sImportCustomHeight: integer; sImportCustomOffset: LongInt; sWandAutoMeasure, sWandAdjustAreas: boolean; sBinaryIterations: integer; sScaleArithmetic: boolean; sInvertPixelValues: boolean; sInvertYCoordinates: boolean; sFieldWidth, sPrecision: integer; sMinParticleSize, sMaxParticleSize: LongInt; sIgnoreParticlesTouchingEdge, sLabelParticles, sOutlineParticles, sIncludeHoles: boolean; sKernelsVRefNum: integer; sKernelsDirID: LongInt; sDefaultVRefNum: integer; sDefaultDirID: LongInt; sOscillatingMovies: boolean; sDriverHalftoning: boolean; sMaxMeasurements: integer; sImportCustomDepth: FileDepthType; sImportSwapBytes, sImportCalibrate, sImportAutoscale: boolean; sUnused2: packed array[1..12] of integer; sShowHeadings: boolean; {Added with V1.40} sProfilePlotMin, sProfilePlotMax: real; sImportMin, sImportMax: real; sHighlightPixels: boolean; {Added with V1.41} sBallRadius: integer; sFasterBackgroundSubtraction: boolean; sScaleConvolutions: boolean; {Added with V1.42} sBinaryCount: integer; sColorTable: ColorTableType; sColorStart, sColorEnd: integer; sInvertedTable: boolean; {Added with V1.44} sHalftoneFrequency, sHalftoneAngle: integer; sHalftoneDotFunction: boolean; {Added with V1.46} sLG3DacLow, sLG3DacHigh: integer; {Added with V1.47} sSyncMode: SyncModeType; {Added with V1.49} sSwitchLUTOnSuspend: boolean; sVideoRateAveraging: boolean; {Added with V1.50} sImportInvert: boolean; {Added with V1.52} sTextCreator: packed array[1..4] of char; sUnused: array[1..10] of LongInt; end; TiffInfoRec = record Width, Height: integer; BitsPerPixel: integer; ZeroIsBlack: boolean; OffsetToData, OffsetToColorMap, OffsetToImageHeader: LongInt; Resolution: extended; ResUnits: (tCentimeters, tInches, tNoUnits); NextIFD: LongInt; end; TiffIFDTable = array[1..MaxSlices] of record iWidth, iHeight: integer; Offset: LongInt; Invert: boolean; end; PaletteRecType = record NumberOfColors: integer; RedData: ColorArray; GreenData: ColorArray; BlueData: ColorArray; end; ProjectionMethodType = (NearestPoint, BrightestPoint, MeanValue); AxisType = (XAxis, YAxis, ZAxis); FiducialMethodType = (OnScreen, FromFile); CoordinatesType = array[1..MaxCoordinates] of integer; xCoordinatesPtr = ^CoordinatesType; yCoordinatesPtr = ^CoordinatesType; WhatToUndoType = (NothingToUndo, UndoEdit, UndoFlip, UndoRotate, UndoFilter, UndoPaste, UndoTransform, UndoClear, UndoMeasurement, UndoPoint, UndoZoom, UndoOutline, UndoSliceDelete, UndoFirstSliceDelete, UndoLUT); TextInfoRec = record TextWindowPtr: WindowPtr; TextLeft, TextTop, TextWidth, TextHeight: integer; hTextScrollBar, vTextScrollBar: ControlHandle; hTextPageSize, vTextPageSize: integer; TextTE: TEHandle; TextTitle: string[31]; TextRefNum: integer; Changes, TooBig: boolean; WindowNum: integer; TxWidNum: integer; end; TextInfoPtr = ^TextInfoRec; packedUnsigned = packed record u: 0..255 end; pup = ^packedUnsigned; packedChar = packed record c: char; end; pcp = ^packedChar; LongIntPtr = ^LongInt; UserInfoHandle = ^UserInfoPtr; UserInfoPtr = ^UserInfoRec; UserInfoRec = record Link: UserInfoHandle; UserWindowPtr: WindowPtr; UserPicBaseHandle: Handle; UserOsPort: CGrafPtr; UserData: Handle; {user's data area} UserUnlockHandles: ProcPtr; UserLockHandles: ProcPtr; UserDispose: ProcPtr; UserActivate: ProcPtr; UserUpdate: ProcPtr; UserGrow: ProcPtr; UserDrag: ProcPtr; UserClose: ProcPtr; UserZoom: ProcPtr; UserMouseDown: ProcPtr; UserCursor: ProcPtr; UserUndo: ProcPtr; UserCut: ProcPtr; UserCopy: ProcPtr; UserPaste: ProcPtr; UserClear: ProcPtr; UserCloseWarning: ProcPtr; UserNewSize: LongInt; UserLoc: Point; UKind: Integer; {field value constants xxxUKind defined in UMacroDef.p} UserActivating: Boolean; end; var TraceInfo: str4; finished: boolean; trect, gmrect, MapRect1, MapRect2, crect, HistoRect: rect; gmSlide1, gmslide2, gmSlide1i, gmSlide2i, gmicon1, gmicon2: rect; ToolWindow, MapWindow, LUTWindow, InfoWindow, HistoWindow, PlotWindow, PasteControl: WindowPtr; BuggyWatch: CursHandle; cr, tab, BackSpace, eof: char; CharCount: LongInt; ScreenPort: GrafPtr; CScreenPort: cGrafPtr; ticks: LongInt; MonoFunction: ClutTable; Info: InfoPtr; UserInfoList: UserInfoHandle; ToolCursor: array[ToolType] of Cursor; AnimatedWatch: array[1..8] of Cursor; WatchIndex: integer; PickerCursor, LUTCursor, gmCursor, CrossPlusCursor, CrossMinusCursor, GlassMinusCursor, watch, WandPlusCursor, WandMinusCursor: Cursor; CurrentTool, PreviousTool, FirstTool, LastTool: ToolType; ToolRect: array[ToolType] of rect; ToolTime, LutTime: longInt; nPics, nextPid, nextTxWid: integer; PicWindow: array[1..MaxPics] of WindowPtr; ScreenWidth, ScreenHeight: integer; ScreenBase: ptr; ScreenRowBytes: LongInt; ScreenPixMap: PixMapHandle; Histogram: HistogramType; HistogramSliceStart, HistogramSliceEnd: integer; ForegroundIndex, BackgroundIndex: integer; lines: array[1..nLineTypes] of rect; CheckRect: rect; LineWidth, LineIndex: integer; StartOfLines: integer; MaskRgn: RgnHandle; PlotPICT: PicHandle; PlotLeft, PlotTop, PlotWidth, PlotHeight, PlotPicNum: integer; PlotMin, PlotMax, ActualPlotMin, ActualPlotMax: real; PlotCount, PlotAvg: integer; PlotData: rLinePtr; PlotAngle, PlotScale: extended; PlotStart: point; PlotXUnits, PlotYUnits: string[15]; InvertPlots, AutoscalePlots, LinePlot, DrawPlotLabels, FixedSizePlot: boolean; ProfilePlotMin, ProfilePlotMax: extended; ProfilePlotWidth, ProfilePlotHeight: integer; UndoBuf, ClipBuf, BigBuf: ptr; ClipBufSize, UndoBufSize, BigBufSize: LongInt; UndoInfoRec: PicInfo; UndoInfo: InfoPtr; CurrentUndoSize: LongInt; SprayCanDiameter, SprayCanRadius, SprayCanRadius2: integer; BrushHeight, BrushWidth: integer; CurrentFontID, CurrentSize, NumFontItems: integer; CurrentStyle: Style; InsertionPoint: point; {Offscreen coordinates} IsInsertionPoint: boolean; TextJust: integer; TextBack: TextBackType; TextStr: str255; TextRect: rect; TextStart: point; BlinkTime: LongInt; pat: array[0..7] of pattern; PatIndex: integer; OpPending: boolean; CurrentOp: OpType; IsOK: boolean; PicLeftBase, PicTopBase, PicLeft, PicTop: integer; ClipBufInfoRec: PicInfo; ClipBufInfo: InfoPtr; MouseState: (NotInRoi, InRoi, DownInRoi); osMouseDownLoc: point; OldRoiRect: rect; WhatsOnClip: (NothingOnClip, AColor, RectPic, NonRectPic, ImportedPic, CameraPic, TextOnClip, LivePic); ClipTextInBuffer: boolean; ExtraColors: ExtraColorsArray; nExtraColors: integer; PasteTransferMode: integer; cheight: integer; ExtraColorsRect: array[1..MaxExtraPlus2] of rect; ExtraColorsEntry: array[1..MaxExtraPlus2] of integer; RoiMode: (MoveMode, StretchMode, LeftEndMode, RightEndMode); OldScrapCount: integer; ClipboardConverted: boolean; results: record UncalibratedMean: extended; MinIndex, MaxIndex, imode: integer; end; FrameGrabber: (QuickCapture, Scion, ScionLG3, NoFrameGrabber); fgSlotBase: LongInt; ControlReg, ChannelReg, BufferReg, DacHighReg, DacLowReg: ptr; Digitizing: boolean; debugging: boolean; NoInfo: InfoPtr; NoInfoRec: PicInfo; UndoFromClip: boolean; DensitySlicing, ThresholdToForeground, NonThresholdToBackground: boolean; SliceStart, SliceEnd: integer; SliceColor: RGBColor; BlankFieldInfo: InfoPtr; BlankFieldMean: integer; InvertVideo, HighlightSaturatedPixels: boolean; VideoChannel: integer; TextBufSize, TextBufColumn, TextBufLineCount: integer; TextBufP: TextBufPtr; BitInfoCount: integer; mCount, mCount2: integer; nPoints, nLengths, nAngles: integer; umean: array[0..MaxStandards] of real; {Uncalibrated means} StandardValues: StandardsArray; nStandards: integer; cvalue: array[0..255] of extended; MinValue, MaxValue, FitGoodness, FitSD: extended; PlotLeftMargin, PlotTopMargin, PlotBottomMargin, PlotRightMargin: integer; WhatToUndo: WhatToUndoType; WhatToCopy: (NothingToCopy, CopySelection, CopyCLUT, CopyGrayMap, CopyTools, CopyPlot, CopyCalibrationPlot, CopyHistogram, CopyMeasurements, CopyColor, CopyText); WhatToPrint: (NothingToPrint, PrintImage, PrintSelection, PrintMeasurements, PrintPlot, PrintHistogram, PrintText); PrintRecord: THPrint; isLaserWriter: boolean; printing: boolean; HalftoneFrequency, HalftoneAngle: integer; HalftoneDotFunction: boolean; AppleMenuH, FileMenuH, AcquireMenuH, ExportMenuH, EditMenuH, OptionsMenuH, ColorTablesMenuH, {} PropagateMenuH, EnhanceMenuH, FilterMenuH, BinaryMenuH, ArithmeticMenuH, BackgroundMenuH, {} AnalyzeMenuH, SpecialMenuH, StacksMenuH, SortPaletteMenuH, FontMenuH, SizeMenuH, StyleMenuH, {} WindowsMenuH, UserMenuH, TransferModeMenuH, LineToolMenuH, ImageMathOpsMenuH, ImageListMenuH, UnitsMenuH: MenuHandle; MacroMenusH: array[FirstMacroMenu..LastMacroMenu] of MenuHandle; rleft, rtop: integer; ListDone: boolean; ResultsWindow: WindowPtr; hScrollBar, vScrollBar: ControlHandle; ListTE: TEHandle; hListPageSize, vListPageSize: integer; measuring: boolean; Measurements: set of MeasurementTypes; nListColumns: integer; FramesToAverage: integer; xLabel, yLabel, zLabel: string[31]; xValueLoc, yValueLoc, zValueLoc: integer; MenuBarHeight: integer; NewPicWidth, NewPicHeight: integer; RestoreUndoBuf: boolean; WhatToOpen: (OpenImage, OpenPICT2, OpenTIFF, OpenMCID, OpenUnknown, OpenImported, OpenCustom); WhatToImport: WhatToImportType; ImportCustomWidth, ImportCustomHeight, ImportCustomSlices: integer; ImportCustomOffset: LongInt; ImportCustomDepth: FileDepthType; ImportSwapBytes, ImportAll, ImportCalibrate, ImportInvert: boolean; IntelByteOrder: boolean; BufferSize: LongInt; MaxScionWidth: integer; isSelectionTool: boolean; SelectionMode: (NewSelection, AddSelection, SubSelection); RoiMovementState: (Unconstrained, Constrained, ConstrainedH, ConstrainedV); pcItem: array[1..npcItems] of record r: rect; itype: pcItemType; str: string[20]; end; PictF: integer; PictBuffer, curPictBufPtr: ptr; BytesInPictBuffer: LongInt; FitsInPictBuffer, RoiNudged, GrayMapReady, RedoSelection: boolean; ThresholdingMode: (DensitySlice, GrayMapThresholding, BinaryImage, NoThresholding); WandAutoMeasure, WandAdjustAreas, RedirectSampling: boolean; LabelParticles, OutlineParticles, IgnoreParticlesTouchingEdge, IncludeHoles: boolean; MinParticleSize, MaxParticleSize: LongInt; OptionKeyWasDown, ScaleArithmetic, FitEllipse, AnalyzingParticles: boolean; WhiteRGB, BlackRGB: RGBColor; BinaryIterations: integer; nMonitors: integer; Monitors: array[1..6] of GDHandle; InfoMessage: str255; fgStartTicks, fgFrameCount: LongInt; SaveAsWhat: SaveAsWhatType; ExportAsWhat: ExportAsWhatType; SaveAllState: (NoSaveAll, SaveAllStage1, SaveAllStage2); InvertPixelValues, InvertYCoordinates, ContinuousHistogram: boolean; fgPort: cGrafPtr; fgWidth, fgHeight: integer; RoiUpdateTime: LongInt; {Time required to draw ROI outline. Set to 0 to force redraw.} FieldWidth: integer; Precision: integer; {Digits to right of decimal point} MeasurementToRedo: integer; Has32BitQuickDraw: boolean; DefaultRefNum, KernelsRefNum, MacrosRefNum: integer; nSaves: integer; MacroLoadRequest: Boolean; MacroLoadHandle: Handle; LaunchVRefNum, PlugInsVRefNum: integer; LaunchDirID, PlugInsDirID: LongInt; DefaultFileName: string[63]; rsHScale, rsVScale, rsAngle: real; {Rotate and Scale Parameters} rsMethod: rsMethodType; rsCreateNewWindow: boolean; rsInteractive: boolean; TextEol, TextEof: boolean; Textf, TextIndex: integer; TextFileSize: LongInt; nMacros, nSymbols: integer; TopOfStack, CurrentX, CurrentY: integer; nProcedures, TokenStackLoc, nGlobals, SymbolTableLoc: integer; LegalWithoutImage: set of CommandType; MacroTicks: LongInt; SaveForeground: integer; PC: LongInt; {"program counter" used by macro interpreter} pcStart, EndMacros, SavePC, TokenLoc: LongInt; MacroLineNumber: integer; MacroItems: MacroItemsHandle; {MacroStart: array[0..MaxMacros] of LongInt;} {MacroKey: packed array[1..MaxMacros] of char;} Token, SaveToken: TokenType; TokenStr: str255; TokenSymbol, MacroOrProcName: SymbolType; TokenValue: extended; Macro: boolean; {True if macro is running.} Macros: LongIntPtr; MacrosP: MacrosPtr; MacroCommand: CommandType; SerialIn, SerialOut: integer; SerialBufferP: ptr; ImportAutoScale: boolean; ImportMin, ImportMax: extended; OscillatingMovies, DriverHalftoning: boolean; ExplicitPalette: PaletteHandle; LivePasteMode: boolean; ShowCount: boolean; PasteControlLeft, PasteControlTop: integer; MaxMeasurements: integer; mean: meanPtr; sd: sdPtr; PixelCount: PixelCountPtr; mArea: AreaPtr; mode: modePtr; IntegratedDensity: IntegratedDensityPtr; idBackground: idBackgroundPtr; xcenter: xcenterPtr; ycenter: ycenterPtr; MajorAxis: MajorAxisPtr; MinorAxis: MinorAxisPtr; orientation: orientationPtr; mMin: MinPtr; mMax: MaxPtr; plength: plengthPtr; User1: User1Ptr; User2: User2Ptr; ResultsLeft, ResultsTop, ResultsWidth, ResultsHeight: integer; UnsavedResults: boolean; MajorLabel, MinorLabel, User1Label, User2Label: string[9]; OldSystem, System7: boolean; SystemRefNum: integer; ShowHeadings: boolean; MakingLOI: boolean; LOIType: (Straight, Freehand, Segmented); MakingStack: boolean; FramesWanted: integer; ScaleConvolutions: boolean; FasterBackgroundSubtraction: boolean; BallRadius: integer; DelayTicks: integer; CmdPeriodToStop: string[21]; CommandKey: char; BinaryCount, BinaryThreshold: integer; ClipboardColor: rgbColor; InitAngle, TotalAngle, AngleInc, {initial, total, and incremental angles of volume rotation} TransparencyLower, {pixels below this threshold are transparent} TransparencyUpper, {pixels above this threshold are transparent} Opacity, {percentage nearest-point in a combined projection} DepthCueSurf, {depth-cueing constant for nearest-pt component} DepthCueInt: integer; {depth-cueing constant for other projection components} AxisOfRotation: AxisType; {project volume as it rotates about x,y,or z-axis} SaveProjections, {if TRUE, save and close proj frames once created} MinProjSize: boolean; {if FALSE, make windows same size regardless of rotation axis} ProjectionMethod: ProjectionMethodType; MeterWindow: WindowPtr; xCoordinates: xCoordinatesPtr; yCoordinates: yCoordinatesPtr; nCoordinates: integer; CoordinatesWidth, CoordinatesHeight: integer; CoordinatesRoiType: RoiTypeType; SwitchLUTOnSuspend: boolean; SumFrames, ExternalTrigger, BlindMovieCapture, ShowIntegratedValues, FixIntegrationScale: boolean; IntegrationMin, IntegrationMax: LongInt; LG3DacHigh, LG3DacLow: integer; MaxLG3Frames: integer; VideoRateAveraging: boolean; VideoControl: DialogPtr; SyncMode: SyncModeType; DitherColor: boolean; RGBLut: (ExistingLUT, SystemLUT, CustomLUT); Highlight1, Highlight254: rgbColor; HighlightMode: boolean; OpeningPlugInWindow: boolean; DacAReg, DacBReg: ptr; LG3DacA, LG3DacB, LG3DataOut: integer; nAcqPlugIns, nExportPlugIns, nFilterPlugIns: integer; LastAcqPlugIn, LastFilterPlugIn, LastExportPlugIn, NewTitle: string[31]; TextInfo: TextInfoPtr; nTextWindows: integer; TextWindow: array[1..MaxTextWindows] of WindowPtr; SearchString: string[31]; CurrentWPtr: WindowPtr; CurrentKind: integer; ToolBits: BitMap; TextCreator: packed array[1..4] of char; CurrentMathOp: (AddMath, SubMath, MulMath, DivMath, AndMath, OrMath, XorMath, MaxMath, MinMath, CopyMath); MathSrc1, MathSrc2: integer; MathGain: real; MathOffset: LongInt; MathResult: string[31]; PrintOptionsSet: boolean; APReset: boolean; ShowPlot: boolean; osGDevice: GDHandle; gCopyMode: integer; SaveScreenDepth: integer; FiducialMethod: FiducialMethodType; ConfirmFidClicks: boolean; WireframeSurfacePlots, GrayscaleSurfacePlots: boolean; implementation end.