locked
How to create a StorageItemThumbnail object by IRandomAccessStream interface?

    Question

  •  I get the RandomAccessStream from Camera, then I want to save the image file's thumbnail object.

    But not by the getThumbnailAsync function.

    StorageItemThumbnail from RandomAccessStream.

    Thanks all.

    Monday, April 01, 2013 10:04 AM

All replies


  • Hi Libby,

    The suggested means to create a StorageItemThumnail object is using getThumbnailAsync method of StorageFile class. When using camera to take a picture, you can consider directly saving it to app's temporary folder (as file) so that you can retrieve thumbnail from it.

    Or if you've only the random access stream format data (or of blob format), you can try converting random access stream to blob which can be used to generate a temporary url. Then, you can use the url to display the image or generate a StorageFile (for retrieving thumbnail image).

    #createBlobFromRandomAccessStream method
    http://msdn.microsoft.com/en-us/library/windows/apps/Hh767329.aspx

    #createObjectURL method
    http://msdn.microsoft.com/en-us/library/windows/apps/hh453196.aspx

    #StorageFile.CreateStreamedFileFromUriAsync | createStreamedFileFromUriAsync method
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.createstreamedfilefromuriasync.aspx

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, April 02, 2013 6:59 AM
    Moderator
  • Thanks Steven.

    If taking more photo at the short time, saving to the temporary folder will be slow, and the UI will be blocked.

    I push the data handler in Winrt by C#, So the blob object will can not be used.

    I use StorageFile.CreateStreamedFileAsync  to get the file, then obtain the StorageItemThumbnail object, but it has two questions.

    one is the thumbnail image's size will not be set.

    the other is the video stream's thumbnail can not be obtained successly.

    Tuesday, April 02, 2013 7:41 AM