Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataPackage.SetBitmap | setBitmap method

Applies to Windows and Windows Phone

Sets the bitmap image contained in the DataPackage.

Syntax


dataPackage.setBitmap(value);

Parameters

value

Type: RandomAccessStreamReference

A stream that contains the bitmap image.

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.

Examples

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


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);
    });
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

See also

DataPackage

 

 

Show:
© 2014 Microsoft