Generated shrinked image when we capture big image via WebView.CapturePreviewToStreamAsync() API. RRS feed

  • Question

  • Hi,

    I am using WebView.CapturePreviewToStreamAsync() API to capture a screenshot of the WebView control contents.
    When the file is too big (I have converted big word file [around 150 page] to html file and opened via WebView control), the saved file is shrinking. The size of the saved file is "x (width) * 65535 (Height)" pixels.
    I have observed that if the generated file height is less than 65535 pixels, contents are properly displaying. If it exceeds 65535 pixels, content is shrinking.

    I am using below code to save a file.

    InMemoryRandomAccessStream msWebViewCtrlData = new InMemoryRandomAccessStream();

    StorageFile storageFileGeneratedFile= await KnownFolders.PicturesLibrary.CreateFileAsync("test.jpeg");

    var fileStream = await storageFileGeneratedFile.OpenAsync(FileAccessMode.ReadWrite);

    await WebViewCtrl.CapturePreviewToStreamAsync(msWebViewCtrlData);

    await RandomAccessStream.CopyAndCloseAsync(msWebViewCtrlData.GetInputStreamAt(0),  fileStream.GetOutputStreamAt(0));

    Could you please help regarding this query.

    Thanks in advance,


    Wednesday, March 19, 2014 10:42 AM


  • It sounds like this might be a built-in feature of WebView, but I am not sure. However, the WebView control sample shows how to scale down a capture - perhaps you could do the reverse and scale it up? I am referencing the code on the documentation page:


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, March 19, 2014 12:24 PM