Macro 'Import HB603 Image'; { Import HB603 Image By Dennis C. Winkler Materials Science and Engineering Department Lehigh University August/September 1996 Imports an HB603 *.IMG image file along with the image information. Produces a graphics window containing the image and microscope information and a text window containing the microscope information, image size, and file path. } var width, height, slices, loop1, loop2, scale, offset, infowidth, RawPID, HeaderTxtPID, ImportPID, FinalImgPID:integer; name, path, temp:string; begin {Set some parameters} infowidth:=160; {About the width of the info strip on a 480x480 image} width:=814; {"Information" containing part (header) of the file} height:=1; offset:=0; slices:=1; {Open the file and get info and image size} SetImport('8-bit'); {We want the info a character at a time.} SetCustom(width,height,offset,slices); Import(''); {Read in header as an image, prompting for file name.} name := WindowTitle; {Get file name} path := GetPath('window'); {Get path} RawPID:=pidnumber; {Get permanent ID number for reference} width:=getpixel(161,0)*256+getpixel(162,0); {Get real image size} height:=width; {The images are square} scale:=width/480; {So we can scale certain items relative to a 480x480 image} {Set up text window to store microscope information} NewTextWindow(concat(name,' - Info (Text)'),200,550); HeaderTxtPID:=pidnumber; MoveWindow(80,40); moveto(0,0); SetText('Left Justified'); SetFont('Helvetica'); SetFontSize(12); for loop1:=0 to 27 do {32 lines of "info" displayed on microscope CRT, most blank, skip last 4 to save time} begin ChoosePic(RawPID); temp:=''; for loop2:=0 to 19 do temp:=concat(temp,chr(getpixel(185+loop2+loop1*21, 0))); ChoosePic(HeaderTxtPID); writeln(temp); end; writeln; writeln(concat('Image Size: ',width,' x ',height)); writeln; writeln(concat('Image Source: ',path,name)); {Set up graphic window for image information and imported image} SetNewSize(infowidth*scale+width,height); MakeNewWindow(concat(name,' - Imported')); FinalImgPID:=pidnumber; MoveWindow(100,60); moveto(0,0); SetForegroundColor(255); SetFontSize(12*scale); writeln; {This is done sequentially (ie. not in the previous loop) because it went faster this way} for loop1:=0 to 27 do {32 lines of display on the microscope CRT, most are blank, skip last 4 to save time} begin ChoosePic(RawPID); temp:=''; for loop2:=0 to 19 do temp:=concat(temp,chr(getpixel(185+loop2+loop1*21, 0))); ChoosePic(FinalImgPID); writeln(temp); end; {Create scale bar} SetLineWidth(1); SetForegroundColor(255); MakeRoi(20*scale,315*scale,122*scale,11*scale); Fill; KillRoi; ChoosePic(RawPID); Dispose; {Import the image} offset:=2132; {Offset to get to the image} SetImport('16-bit Unsigned,swap bytes'); SetCustom(width, height, offset, slices); Import(''); {No prompt this time; Import remembers the name.} ImportPID:=pidnumber; {Now copy image into the final image} SelectAll; {Select imported image to copy} Copy; ChoosePic(FinalImgPID); MakeRoi(infowidth*scale,0,width,height); Paste; KillRoi; {Clean up} ChoosePic(ImportPID); Dispose; SetFontSize(12); PutMessage(concat('Finished!',chr(13),chr(13),'"Import HB603 Image"',chr(13),' - by Dennis C. Winkler')); end;