Raster - move + scale + rotate


Properties from attached raster files in MicroStation can be modified using the Rastermanager.
Also VBA supports the Rastermanager to modify these properties.

The following VBA example is demonstrating how an attached raster file can be selected and the position changed, scaled and rotated.

Sub ModifyRaster()

Dim oRaster As Raster
Dim origin As Point3d
Dim size As Point2d
Dim rotat As Double

        Set oRaster = RasterManager.Rasters.Item("D:\raster\test.jpg")
        Debug.Print "Filename: " & oRaster.RasterInformation.Name
        
        ' Modifying size:
        size = oRaster.GeoReferenceInformation.Extent
        Debug.Print "Old size(xy): " & size.X, size.Y
        ' scale size with 1.5
        size.X = size.X * 1.5
        size.Y = size.Y * 1.5
        oRaster.GeoReferenceInformation.Extent = size
        Debug.Print "New size(xy): " & oRaster.GeoReferenceInformation.Extent.X, oRaster.GeoReferenceInformation.Extent.Y
        
        ' Modifying origin:
        origin = oRaster.GeoReferenceInformation.origin
        Debug.Print "Old origin (xy): " & origin.X, origin.Y
        ' set new origin:
        origin = Point3dFromXYZ(150, 250, 0)
        oRaster.GeoReferenceInformation.origin = origin
        Debug.Print "New Origin (xy): " & oRaster.GeoReferenceInformation.origin.X, oRaster.GeoReferenceInformation.origin.Y
        
        ' Rotate raster:
        rotat = oRaster.GeoReferenceInformation.RotationAboutZ
        Debug.Print "old rotation (degrees): " & Degrees(rotat) & "°"
        rotat = Radians(65)  ' rotate about 65°
        oRaster.GeoReferenceInformation.RotationAboutZ = rotat
        Debug.Print "new rotation (degrees): " & Degrees(oRaster.GeoReferenceInformation.RotationAboutZ) & "°"
End Sub