DeviceThumbnail DeviceThumbnail DeviceThumbnail DeviceThumbnail Class

Definition

Represents the thumbnail image for a device.

public : sealed class DeviceThumbnail : IClosable, IContentTypeProvider, IInputStream, IOutputStream, IRandomAccessStream, IRandomAccessStreamWithContentType
public sealed class DeviceThumbnail : IDisposable, IContentTypeProvider, IInputStream, IOutputStream, IRandomAccessStream, IRandomAccessStreamWithContentType
Public NotInheritable Class DeviceThumbnail Implements IDisposable, IContentTypeProvider, IInputStream, IOutputStream, IRandomAccessStream, IRandomAccessStreamWithContentType
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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 CanRead CanRead CanRead

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

public : Platform::Boolean CanRead { get; }
public bool CanRead { get; }
Public ReadOnly Property CanRead As bool
var bool = deviceThumbnail.canRead;
Value
Platform::Boolean bool bool bool

True if the stream can be read from. Otherwise, false.

CanWrite CanWrite CanWrite CanWrite

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

public : Platform::Boolean CanWrite { get; }
public bool CanWrite { get; }
Public ReadOnly Property CanWrite As bool
var bool = deviceThumbnail.canWrite;
Value
Platform::Boolean bool bool bool

True if the stream can be written to. Otherwise, false.

ContentType ContentType ContentType ContentType

Returns the content type of the thumbnail image.

public : Platform::String ContentType { get; }
public string ContentType { get; }
Public ReadOnly Property ContentType As string
var string = deviceThumbnail.contentType;
Value
Platform::String string string string

The content type of the image.

Position Position Position Position

Gets the byte offset of the stream.

public : ulong Position { get; }
public ulong Position { get; }
Public ReadOnly Property Position As ulong
var ulong = deviceThumbnail.position;
Value
ulong ulong ulong ulong

The number of bytes from the start of the stream.

Size Size Size Size

Gets or sets the size of the device thumbnail image.

public : ulong Size { get; set; }
public ulong Size { get; set; }
Public ReadWrite Property Size As ulong
var ulong = deviceThumbnail.size;
deviceThumbnail.size = ulong;
Value
ulong ulong ulong ulong

The size of the device thumbnail image.

Methods

CloneStream() CloneStream() CloneStream() CloneStream()

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

public : IRandomAccessStream CloneStream()
public IRandomAccessStream CloneStream()
Public Function CloneStream() As IRandomAccessStream
var iRandomAccessStream = deviceThumbnail.cloneStream();
Returns

The new stream. The initial, internal position of the stream is 0.

Close() Close() Close() Close()

Closes the current stream and releases system resources.

public : void Close()
This member is not implemented in C#
This member is not implemented in VB.Net
deviceThumbnail.close();

Dispose() Dispose() Dispose() Dispose()

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

This member is not implemented in C++
void Dispose()
Sub Dispose
void Dispose()

FlushAsync() FlushAsync() FlushAsync() FlushAsync()

Flushes data asynchronously in a sequential stream.

public : IAsyncOperation<Platform::Boolean> FlushAsync()
public IAsyncOperation<bool> FlushAsync()
Public Function FlushAsync() As IAsyncOperation( Of bool )
var iAsyncOperation = deviceThumbnail.flushAsync();
Returns

The stream flush operation.

GetInputStreamAt(UInt64) GetInputStreamAt(UInt64) GetInputStreamAt(UInt64) GetInputStreamAt(UInt64)

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

public : IInputStream GetInputStreamAt(unsigned __int64 position)
public IInputStream GetInputStreamAt(UInt64 position)
Public Function GetInputStreamAt(position As UInt64) As IInputStream
var iInputStream = deviceThumbnail.getInputStreamAt(position);
Parameters
position
unsigned __int64 UInt64 UInt64 UInt64

The position in the input stream.

Returns

A pointer to an input stream.

GetOutputStreamAt(UInt64) GetOutputStreamAt(UInt64) GetOutputStreamAt(UInt64) GetOutputStreamAt(UInt64)

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

public : IOutputStream GetOutputStreamAt(unsigned __int64 position)
public IOutputStream GetOutputStreamAt(UInt64 position)
Public Function GetOutputStreamAt(position As UInt64) As IOutputStream
var iOutputStream = deviceThumbnail.getOutputStreamAt(position);
Parameters
position
unsigned __int64 UInt64 UInt64 UInt64

The position in the output stream.

Returns

A pointer to an output stream.

ReadAsync(IBuffer, UInt32, InputStreamOptions) ReadAsync(IBuffer, UInt32, InputStreamOptions) ReadAsync(IBuffer, UInt32, InputStreamOptions) ReadAsync(IBuffer, UInt32, InputStreamOptions)

Returns an asynchronous byte reader object.

public : IAsyncOperationWithProgress<IBuffer, unsigned int> ReadAsync(IBuffer buffer, unsigned int count, InputStreamOptions options)
public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, UInt32 count, InputStreamOptions options)
Public Function ReadAsync(buffer As IBuffer, count As UInt32, options As InputStreamOptions) As IAsyncOperationWithProgress( Of IBuffer )( Of uint )
var iAsyncOperationWithProgress = deviceThumbnail.readAsync(buffer, count, options);
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

The buffer into which the asynchronous read operation places the bytes that are read.

count
unsigned int UInt32 UInt32 UInt32

The number of bytes to read.

options
InputStreamOptions InputStreamOptions InputStreamOptions InputStreamOptions

Specifies the type of the asynchronous read operation.

Returns

Seek(UInt64) Seek(UInt64) Seek(UInt64) Seek(UInt64)

Sets the position of the stream to the specified value.

public : void Seek(unsigned __int64 position)
public void Seek(UInt64 position)
Public Function Seek(position As UInt64) As void
deviceThumbnail.seek(position);
Parameters
position
unsigned __int64 UInt64 UInt64 UInt64

The new position of the stream.

WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer)

Writes data asynchronously in a sequential stream.

public : IAsyncOperationWithProgress<unsigned int, unsigned int> WriteAsync(IBuffer buffer)
public IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
Public Function WriteAsync(buffer As IBuffer) As IAsyncOperationWithProgress( Of uint )( Of uint )
var iAsyncOperationWithProgress = deviceThumbnail.writeAsync(buffer);
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

The buffer into which the asynchronous writer operation writes.

Returns

The byte writer operation.