Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.81 KB

devicethumbnail.md

File metadata and controls

58 lines (44 loc) · 1.81 KB
-api-id -api-type
T:Windows.Devices.Enumeration.DeviceThumbnail
winrt class

Windows.Devices.Enumeration.DeviceThumbnail

-description

Represents the thumbnail image for a device.

-remarks

Call DeviceInformation.GetThumbnailAsync and handle the completion event as shown in the example.

-examples

// Takes a parameter of type DeviceInformation
// and retrieves a DeviceThumbnail to pass to displayImage().
function getImage (device) {   

    var thumbnail = null;
    if (device){
        device.getThumbnailAsync().then(
            function (thumbnail) {
                if (thumbnail){      
                    if (thumbnail.size > 0) {
                        displayImage(thumbnail);
                    }                                                                      
                 }     
             });
    }                                                                                     
}

function displayImage(imageFile) {
   
    try {
        // Setting 2nd parameter to 'false' cleans up 
        // the URL after first use.
        // We set this because we only need to load the URL
        // into the image tag once.
        document.getElementById("deviceImage").src = 
            window.URL.createObjectURL(imageFile, false);
    } catch (e) {
        document.getElementById("statusMessage").innerHTML = 
            "Could not display image, error: " + e.message;
    }
                
}

-see-also