Gets a full-size Bitmap of the raster dataset.

Namespace:  ESRI.ArcGISExplorer.Data

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public Bitmap GetBitmap()
Visual Basic (Declaration)
Public Function GetBitmap As Bitmap

Return Value

A Bitmap object representing the raster dataset.

Remarks

Common sense is required when using this method given that raster datasets can be extremely large (e.g satellite imagery, aerial photos). Using the method in these cases could result in an OutOfMemoryException exception and application crash. A sensible use of the method would be to get the Bitmap for a photo stored in a Raster column in a file geodatabase feature class.

Examples

The code below demonstrates the GetBitMap method. A file geodatabase feature class of mountains in Scotland is searched to find any rows within 100 meters of the users clicked location. For each mountain, if a raster is present in the Photo column, the GetBitmap method is used to display the image in a PopupWindow.
CopyC#
{
  MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
  Map map = disp.Map;

  //Get the FeatureLayer
  FeatureLayer mountains = map.FindByName("mountains") as FeatureLayer;

  //Get the Table
  Table mountainsTable = mountains.Table;

  //Get the user clicked location
  ESRI.ArcGISExplorer.Geometry.Point clickedPoint = disp.TrackPoint();

  //Return the rows which are within 100 meters of the clicked location
  RowCollection foundMountains = mountainsTable.SearchByDistance(clickedPoint, 100, Unit.Linear.Meters);

  //Loop around found rows
  foreach (Row mountain in foundMountains)
  {
    //Get the Raster stored in the "Photo" Column
    Raster photoOfMtn = mountain.Values["Photo"] as Raster;

    if (photoOfMtn != null)
    {
      //Get the photo as a Bitmap
      System.Drawing.Bitmap photo = photoOfMtn.GetBitmap();

      //Save the bitmap to a temporary location on disk
      //so that it can be loaded into a PopupWindow
      string pathToTempSavedPhoto = @"C:\temp\Mountain" + Guid.NewGuid().ToString() + ".png";
      photo.Save(pathToTempSavedPhoto);
      photo.Dispose();

      //Create a URI for the saved file
      Uri uri = new Uri(pathToTempSavedPhoto);

      //Show the image in a Popup               
      Popup popup = new Popup(disp, uri.ToString(), mountain.Values["Name"].ToString());
      popup.Activate();
    }
  }
}
CopyVB.NET
Dim disp As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
Dim myMap As Map = disp.Map

'Get the FeatureLayer
Dim mountains As FeatureLayer = DirectCast(myMap.FindByName("mountains"), FeatureLayer)

'Get the Table
Dim mountainsTable As Table = mountains.Table

'Get the user clicked location
Dim clickedPoint As ESRI.ArcGISExplorer.Geometry.Point = disp.TrackPoint()

'Return the rows which are within 100 meters of the clicked location
Dim foundMountains As RowCollection = mountainsTable.SearchByDistance(clickedPoint, 100, Unit.Linear.Meters)

'Loop around found rows
For Each mountain As Row In foundMountains
  'Get the Raster stored in the "Photo" Column
  Dim photoOfMtn As Raster = TryCast(mountain.Values.Item("Photo"), Raster)

  If Not photoOfMtn Is Nothing Then
    'Get the photo as a Bitmap
    Dim photo As System.Drawing.Bitmap = photoOfMtn.GetBitmap()

    'Save the bitmap to a temporary location on disk
    'so that it can be loaded into a PopupWindow
    Dim pathToTempSavedPhoto As String = "C:\temp\Mountain" & Guid.NewGuid().ToString() & ".png"
    photo.Save(pathToTempSavedPhoto)
    photo.Dispose()

    'Create a URI for the saved file
    Dim aUri As Uri = New Uri(pathToTempSavedPhoto)

    'Show the image in a Popup
    Dim aPopup As Popup = New Popup(disp, aUri.ToString(), mountain.Values.Item("Name").ToString())
    aPopup.Activate()

  End If
Next

See Also