DataPackage.SetBitmap(RandomAccessStreamReference) DataPackage.SetBitmap(RandomAccessStreamReference) DataPackage.SetBitmap(RandomAccessStreamReference) DataPackage.SetBitmap(RandomAccessStreamReference) DataPackage.SetBitmap(RandomAccessStreamReference) Method

Definition

Sets the bitmap image contained in the DataPackage.

public : void SetBitmap(RandomAccessStreamReference value)
void SetBitmap(RandomAccessStreamReference value) const;
public void SetBitmap(RandomAccessStreamReference value)
Public Sub SetBitmap(value As RandomAccessStreamReference)
dataPackage.setBitmap(value);

Parameters

Examples

The following example uses the setBitmap method to share an image with a target app.

void DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
    DataRequestDeferral deferral = e.Request.GetDeferral();
    e.Request.Data.Properties.Title = "Hello World!";
    e.Request.Data.Properties.Description = "This example shows how to share files and images.";
    if (this.dataPackageThumbnail != null)
    {
        e.Request.Data.Properties.Thumbnail = this.dataPackageThumbnail;
    }
    e.Request.Data.SetBitmap(imageStreamRef);
    deferral.Complete();
}
function registerForShare() {
    var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
    dataTransferManager.addEventListener("datarequested", shareImageHandler);
}

function shareImageHandler(e) {
    var request = e.request;
    request.data.properties.title = "Share Image Example";
    request.data.properties.description = "A demonstration that shows how to share an image.";
    var deferral = request.getDeferral();
    Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\smalllogo.png").then(function (thumbnailFile) {
        request.data.properties.thumbnail = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(thumbnailFile);
        return Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\logo.png");
    }).done(function (imageFile) {
        request.data.setBitmap(Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile));
        deferral.complete();
    }, function (err) {
        request.failWithDisplayText(err);
    });
}

Remarks

This method sets the value for StandardFormats.Bitmap.

Bitmap is one of the data types that the DataPackage object supports directly. See the StandardDataFormats class for information on other supported data types.