Vous êtes sur la page 1sur 2

Raster image tables (tables that display only raster image data, not vector data)

do not have all of


the component files listed above, because raster image tables do not contain
tabular data. Every
raster image table consists of at least two files: a .tab file (which stores the
image’s control points)
and the file or files that store the raster image. For example, if a raster image
table is based on the
file photo.tif, the table might consist of two files: photo.tif and photo.tab.
In many ways, a raster image table is just like any other table. To open a raster
image table, use an
Open Table statement. To display a raster image table in a Map window, issue a Map
statement. To
add a raster image table to an existing map, issue an Add Map Layer statement.
However, you
cannot perform a Select operation on a raster image table. To determine if a table
is a raster table,
call TableInfo( ) with the TAB_INFO_TYPE code. If the table is a raster table,
TableInfo( ) returns
the code TAB_TYPE_IMAGE. As a rule, MapInfo Professional does not alter the
original image file
on which a raster table is based. Therefore:
• If you use the Drop Table statement to delete a raster table, MapInfo
Professional deletes the
table file, but does not delete the image file on which the table is based.
• If you use the Rename Table statement on a raster table, MapInfo Professional
renames the
table file, but does not rename the image file on which the table is based.
• If you use the Commit statement to copy a raster table, MapInfo Professional
copies the table
file but does not copy the image file on which the table is based.
Include "mapbasic.def
Declare Sub Main
Declare Function register_nonmap_image(ByVal filename As String,
ByVal tablename As String) As Logical
Sub Main
Dim fname, tname As String
fname = "c:\data\raster\photo.gif" ’name of an existing image
tname = PathToDirectory$(fname)
+ PathToTableName$(fname) + ".tab" ’name of table to create
If FileExists(tname) Then
Note "The image file is already registered; stopping."
Else
If register_nonmap_image(fname, tname) Then
Note "Table file created for the image file: "
+ fname + "."
Else
Note "Could not create table file."
End If
End If
End Sub
Function register_nonmap_image( ByVal filename As String,
ByVal tablename As String) As Logical
register_nonmap_image = FALSE
OnError GoTo handler
Open File tablename For Output As #1 FileType "MIta"
Print #1, "!Table"
Print #1, "!Version 300"
Print #1, "!charset Neutral"
Print #1
Print #1, "Definition Table"
Print #1, " File """ + filename + """"
Print #1, " Type ""RASTER"" "
Print #1, " (1,1) (1,1) Label ""Pt 1"", "
Print #1, " (5,1) (5,1) Label ""Pt 2"", "
Print #1, " (5,5) (5,5) Label ""Pt 3"" "
Print #1, " CoordSys NonEarth Units ""mm"" "
Print #1, " Units ""mm"" "
Print #1, " RasterStyle 1 45" ’ Brightness; default is 50
Print #1, " RasterStyle 2 60" ’ Contrast; default is 50
Close File #1
register_nonmap_image = TRUE ’ set function return value
last_exit:
Exit Function
handler:
Close File #1
Resume last_exit
End Function

Vous aimerez peut-être aussi