unit realUtils; interface uses Memory, QuickDraw, Packages, Menus, Events, Fonts, ToolUtils, globals, Utilities, Graphics; function NewRealWindow (name: str255; width, height: LongInt): boolean; procedure DisplayRealImage(rData: rImagePtr; min, max: real; BlackIsZero: boolean); function ConvertToReal:boolean; implementation function NewRealWindow (name: str255; width, height: LongInt): boolean; var TempH: handle; begin tempH := GetBigHandle(width * height * SizeOf(real)); if TempH = nil then begin PutMemoryAlert; NewRealWindow := false; exit(NewRealWindow); end; if not NewPicWindow(name, width, height) then begin DisposeHandle(handle(TempH)); exit(NewRealWindow); end; info^.DataH := tempH; UpdateTitleBar; UpdateWindowsMenuItem; NewRealWindow := true; end; procedure DisplayRealImage(rData: rImagePtr; min, max: real; BlackIsZero: boolean); var row, col, i, base, width, height: LongInt; r, scale: real; line: lineType; begin with info^ do begin width := pixelsPerLine; height := nLines; end; scale := 255.0 / (max - min); for row := 0 to height - 1 do begin base := row * width; for col := 0 to width - 1 do begin r := rData^[base + col]; line[col] := round((r - min) * scale); end; PutLine(0, row, width, line); end; if BlackIsZero then InvertPic; with info^ do begin Changes := true; fit:=StraightLine; nCoefficients := 2; if BlackIsZero then begin coefficient[1] := max; coefficient[2] := -1.0/scale; end else begin coefficient[1] := min; coefficient[2] := 1.0/scale; end; nKnownValues := 0; ZeroClip := false; UpdateTitleBar; end; end; function ConvertToReal:boolean; var row, col, i, sum, base: LongInt; width, height: LongInt; line: LineType; rData: rImagePtr; TempH: handle; begin with info^ do begin width := pixelsPerLine; height := nLines; tempH := GetBigHandle(width * height * SizeOf(real)); if TempH = nil then begin PutMemoryAlert; ConvertToReal := false; exit(ConvertToReal); end; dataH := tempH; hlock(dataH); rData := rImagePtr(dataH^); end; for row:= 0 to height - 1 do begin GetLine(0, row, width, line); base := row * width; for col := 0 to width - 1 do rData^[base + col] := line[col]; end; hunlock(info^.dataH); UpdateTitleBar; UpdateWindowsMenuItem; ConvertToReal := true; end; end. {realUtils Unit}