locked
[UWP]Black Screen caputre in UWP Intel NUC device and os version is Aniversary (os build 14393.2485) RRS feed

  • Question

  • Hi,

    I have created functionality in UWP to capture screen shot of  running content for Intel NUC device , content will be pdf, images or video what i am facing when i click on capture button.

    It takes screen correctly but in case of video it will create black box rather then media element  on captured image.

    this code is running fine when i running on my desktop machine os version 1803 but not working on

    Inten NUC  aniversary os build 14393.2485 version 1607

    my code is return below.

    try
                {
                    RenderTargetBitmap rtb = new RenderTargetBitmap();
                    var displayInformation = DisplayInformation.GetForCurrentView();
                    await rtb.RenderAsync(control, (int)displayInformation.ScreenWidthInRawPixels, (int)displayInformation.ScreenHeightInRawPixels);
                    var pixelBuffer = await rtb.GetPixelsAsync();
                    var pixels = pixelBuffer.ToArray();
                    var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(folderName, CreationCollisionOption.OpenIfExists);
                    var file = await folder.CreateFileAsync(fileNameWithExtentionType, CreationCollisionOption.ReplaceExisting);
                    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
                        encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                             BitmapAlphaMode.Premultiplied,
                                             (uint)rtb.PixelWidth,
                                             (uint)rtb.PixelHeight,
                                             displayInformation.RawDpiX,
                                             displayInformation.RawDpiY,
                                             pixels);
                        await encoder.FlushAsync();
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.ExceptionLogging(ex, "PDSUtility.ScreenCapture");
                }


    Arun Singh Rawat | Mobility | UWP| WPF Skype: arun.rawat017 | Email:arun.rawat017@hotmail.com| arun.rawat017@gmail.com



    Friday, September 14, 2018 6:28 AM

All replies

  • Hello,

    UWP Intel NUC device looks like a mini PC which may lack of something to support what you want. So when you said "but in case of video it will create black box rather then media element", do you mean you are capture images and are trying to use MediaComposition to combine clips? This is not showed in your code, so maybe you have some other code which is not showing?

    Does NUC device installed Windows Media Play related component? Can you find any errors from your app? If you cannot find it when debugging, what about check the Event Viewer from your control panel, can you find any info? 

    Personally I guess that the mini PC missed something but we need some more info in order to find it out.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 17, 2018 5:18 AM
  •   

    Hi

    I used below code for capturing screenshots, Its working fine with above Anniversary update OS. But In my project minimum target support is anniversary update. Its given me black screenshot when I run my app into anniversary update machine.

    SOURCE CODE-

     public async static void ScreenCapture(UIElement control, string fileNameWithExtentionType, string folderName = PDSConstants.SCREEN_CAPTURE_FOLDER_NAME)
            {
                try
                {
                    RenderTargetBitmap rtb = new RenderTargetBitmap();
                    var displayInformation = DisplayInformation.GetForCurrentView();
                    await rtb.RenderAsync(control, (int)displayInformation.ScreenWidthInRawPixels, (int)displayInformation.ScreenHeightInRawPixels);
                    var pixelBuffer = await rtb.GetPixelsAsync();
                    var pixels = pixelBuffer.ToArray();
                    var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(folderName, CreationCollisionOption.OpenIfExists);
                    var file = await folder.CreateFileAsync(fileNameWithExtentionType, CreationCollisionOption.ReplaceExisting);
                    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
                        encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                             BitmapAlphaMode.Premultiplied,
                                             (uint)rtb.PixelWidth,
                                             (uint)rtb.PixelHeight,
                                             displayInformation.RawDpiX,
                                             displayInformation.RawDpiY,
                                             pixels);
                        await encoder.FlushAsync();
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.ExceptionLogging(ex, "PDSUtility.ScreenCapture");
                }
            }

    pls provide any solution for same.


    sandeep chauhan

    • Merged by Barry Wang Monday, September 24, 2018 8:07 AM same issue
    Wednesday, September 19, 2018 10:43 AM
  • Hi,

    As it could work correctly in higher version, it seems this problem is fixed in later updates. So my suggestion is that you could target higher version than anniversary update. 

    Another thing is that starting in Windows 10, version 1803, the Windows.Graphics.Capture namespace provides APIs to acquire frames from a display or application window, to create video streams or snapshots to build collaborative and interactive experiences. You could get more information here:

    Screen capture

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 20, 2018 6:15 AM
  • Hi Roy

    Thanks for reply.

    Actually As per requirement, I need to target minimum anniversary update OS for our app. That's why we are facing more issue which depends on OS.

    Is there any another way to capture screen which support for Anniversary Update OS or any sample code?

    Thanks

    Sandeep


    sandeep chauhan

    Thursday, September 20, 2018 7:50 AM
  • Hi,

    Well, in my understanding, if you want to do this in other ways, you may have to consider develop a desktop app and then convert and use our Desktop Converter technology. 

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 21, 2018 6:43 AM