Copy Content of Hosted Silverlight Control
Asked Answered
D

2

6

EDIT: Since my original problem was due to my mistake I will rephrase this question.

Im hosting a Silverlight in a window inside my C++ application based on the code found here.

Now I'd like to copy the content of the control to memory in order to use the content inside my own renderer. The problem I have is that when I set "EnableGPUAcceleration" to true, then BitBlt stops working, all I get is blackness.

I feel that in theory there should be a way to copy the content of a GPU-accelerated Silverlight control with its alpha, e.g. with something like glReadPixels.

Anyone got any idea as how to copy the content with alpha of a non-windowless gpu-accelerated Silverlight control?

Another problem is that the window must be visible and no other window may overlap it, otherwise I do not get the proper content. I would like the hosting window to be invisible.

Working sample code can be found here (although without the actual BitBlt"ting" that I'm trying to get to work).

Dunant answered 24/1, 2011 at 8:18 Comment(2)
Do you have a sample code that actually demonstrates your alpha problem? Because the CodeProject's hosted Silverlight control can be copied successfully with BitBlt, right? Or am I missing something?Seitz
@Simon: You are actually correct. My test code was incorrect.Dunant
P
2

I will start researching this, I have an idea that OpenCL or perhaps since you are using Silverlight, DirectCompute may be able to set up a context where you can have more flexibility.

One way would be to simply do all GPU acceleration in one of those languages. Meanwhile I'll try to find out if you can use one of them to grab the information you need or some other techniques.

This link seems to verify that you will need GPU acceleration enabled across any interactive members.

EDIT:

I think that article may provide some other help to your issue. Essentially it is going to be about accessing the cache and ensuring that you are using the cache. Anything set to be in cache mode will be stored on the graphics card temporarily.

This article also sheds some light on the issues. Where it speaks on hardware rendering, it is important to note which operations would cause issues with the cache.

I must admit I'm not at all fluent in Silverlight, but these types of problems are familiar. Doing what I can to understand the situation of your code.

Peyote answered 27/1, 2011 at 9:37 Comment(0)
V
-1

Sadly you can't (IMHO).

If you enable acceleration then all video processing is done in the gpu and output to screen using a hardware overlay buffer. therefore is not acccessible.

The same is true for print screen function on windows. unless you can access the gpu and extract the pixels you are in trouble.

Take a look at the screenshots section here ... http://en.wikipedia.org/wiki/Hardware_overlay

I am a novice on silverlight and therefore don't know what's available, but can you extract the data before it is rendered. This may slow the application down dramatically though. gpu acceleration is designed to remove cpu and bandwidth restrictions, thus anything that gets into the path will slow it down. you may also trigger the tilt bit (DRM) disabling everything.

DC

Viperish answered 1/2, 2011 at 3:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.