Udostępnij za pośrednictwem


DeviceThumbnail Class

Definition

Represents the thumbnail image for a device.

public ref class DeviceThumbnail sealed : IClosable, IRandomAccessStreamWithContentType
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DeviceThumbnail final : IClosable, IRandomAccessStreamWithContentType
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DeviceThumbnail : System.IDisposable, IRandomAccessStreamWithContentType
Public NotInheritable Class DeviceThumbnail
Implements IDisposable, IRandomAccessStreamWithContentType
Inheritance
Object Platform::Object IInspectable DeviceThumbnail
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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

}

Remarks

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

Properties

CanRead

Gets a value that indicates whether the stream can be read from.

CanWrite

Gets a value that indicates whether the stream can be written to.

ContentType

Returns the content type of the thumbnail image.

Position

Gets the byte offset of the stream.

Size

Gets or sets the size of the device thumbnail image.

Methods

CloneStream()

Creates a new instance of a IRandomAccessStream over the same resource as the current stream.

Close()

Closes the current stream and releases system resources.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

FlushAsync()

Flushes data asynchronously in a sequential stream.

GetInputStreamAt(UInt64)

Returns a pointer to an input stream starting at the specified location.

GetOutputStreamAt(UInt64)

Returns a pointer to an output stream starting at the specified location.

ReadAsync(IBuffer, UInt32, InputStreamOptions)

Returns an asynchronous byte reader object.

Seek(UInt64)

Sets the position of the stream to the specified value.

WriteAsync(IBuffer)

Writes data asynchronously in a sequential stream.

Applies to