spm file is consists on two parts: - the header (Total size 512 bytes) - data (the image is recorded in matrix line by line) Here is the VB6 procedure of recording spm data. Put the next code in module: ---------------------------------------------------------------------------------------- Type Header ' User structure definition (SPM header) tx As Integer ' Number of points in one step mx As Integer ' Matrix size on X direction ty As Integer ' Number of points in one step my As Integer ' Matrix size on Y direction kx As Single ' X=mx*kx ky As Single ' Y=my*ky Kz As Single ' Z=matrix value * kz ZUnit As String * 4 ' Label of z-axis XYUnit As String * 4 ' Label of scanning plane sLenght As Integer ' String length Text As String * 320 ' Notification string pole As String * 98 ' Rest for reserve VERSION As String * 64 ' Version of SPM "Nanotop" End Type Public SPMHead As Header ' Declare variable SPMHead of type "Header" ---------------------------------------------------------------------------------------- Next, open the file and write the header from your form ---------------------------------------------------------------------------------------- SPMHead.mx = MaxPoint ' For example, 128 for 128x128 point image SPMHead.my = SPMHead.mx ' Assuming square field SPMHead.kx = MaxArea / (MaxPoint - 1) ' For example, 30000nm / 128 points SPMHead.ky = SPMHead.kx ' The same SPMHead.Kz = MaxZValue * Kz ' Coefficient for Z-direction (local height of the surface) SPMHead.VERSION = "Nanotop205-M file of profile image" ' No comments SPMHead.ZUnit = "nm" + Chr(0) ' Height in "nm" SFNumber = FreeFile Open FileName For Random As #SFNumber Len = Len(SPMHead) ' The FileName variable must be fixed before this operation Position = 1 ' Define record number. Put #SFNumber, Position, SPMHead ' Put the header into the file Close #SFNumber ' Close the file ---------------------------------------------------------------------------------------- Than, save the data: ---------------------------------------------------------------------------------------- SFNumber = FreeFile Open FileName For Random As #SFNumber Len = 2 ' Variable Len is set up as 2 because each saving data has 2 bytes Position = 257 ' Define record number. For Y = 0 To MaxPoint - 1 For X = 0 To MaxPoint - 1 Put #SFNumber, Position, ZMatrixSquare(Y, X) ' ZMatrixSquare contains local heights of the surface Position = Position + 1 ' Next position, next data Next Next Close #SFNumber ' Close the file ---------------------------------------------------------------------------------------- For reading spm data: ---------------------------------------------------------------------------------------- FileNumber = FreeFile 'free file number to open Open FileName For Random As #FileNumber Len = Len(SPMHead) 'Open file ' The value of each record is equal to the lengh of the SPMHeader Position = 1 ' Define record number. Get #FileNumber, Position, SPMHead ' Read first record. ' Display X and Y parameters of image SPM_Version = Trim(Left(SPMHead.VERSION, 7)) If SPM_Version = "Nanotop" Then 'Valid data file Xvalue = SPMHead.mx Yvalue = SPMHead.my XSize = SPMHead.mx * SPMHead.kx YSize = SPMHead.my * SPMHead.ky NSize = SPMHead.mx Kz = SPMHead.Kz ' Define values for next using End If Close #FileNumber ' Close file before reopening in another mode ---------------------------------------------------------------------------------------- Dim tmpdat As Integer Dim PicPoints() As Integer 'Loaded matrix of image ReDim PicPoints(Yvalue - 1, Xvalue - 1) ' Set the array dimensions FileNumber = FreeFile 'free file number to open Open FileName For Random Access Read As #FileNumber Len = 2 ' The value of each record is 2 bytes because data is integer Position = 257 ' SPMHeader size / record lengh - 1 For Y = 0 To Yvalue - 1 ' Array is [0..Yvalue - 1,0..Xvalue - 1] For X = 0 To Xvalue - 1 Get #FileNumber, Position, tmpdat ' Read data from file to tmpdat PicPoints(Y, X) = tmpdat ' array[x,y]=tmpdat 'DArray(X + 1, Y + 1) = tmpdat Position = Position + 1 ' Define the number of the next record Next Next Close #FileNumber ' Close file ---------------------------------------------------------------------------------------- From now, your PicPoints() array contain necessary data for visualization or conversion Good luck!