Ziphnor replied to Ziphnor's topic in Graphics and GPU ProgrammingI guess i should try to RTFM :) I was not creating my offscreen surface in the default pool and hence StretchRect didnt work. After changing to the default pool the stretchrect copy worked and i could also save the resulting surface to a bmp file with D3DXSaveSurfaceToFile. However, i still need to return something easily translated to a Bitmap object to the managed side. Im considering just returning the ARGB surface, and using SurfaceLoader on the managed side to write to a stream from which the bitmap can be created (maybe not terribly efficient, but it doesnt have to be, as this whole thing is a rare occurrence). If you read this far, you might as well give me a suggestion on the cleanest way to do this ;)
Ziphnor posted a topic in Graphics and GPU ProgrammingHi, Im messing around in an application that uses VMR9 Renderless for video playback. The VMR passes a surface containing the video to the (native C++ part of the) application. I would very much like to convert this surface into an RGB bitmap (preferably one that i can easily pass back to managed .NET in a way that makes it easy to convert it to a Bitmap object). The surface in question uses D3DPOOL_DEFAULT and can be locked. However, the format can vary based on the video playing, but will probably be a YUV style format most of the time. For example in my test run it was FOURCC(NV12). My first attempt was to just do Surface s = new Surface(new IntPtr(pSurface)) on the managed side, but that doesnt work, maybe because of the format. My second attempt was to try surface->GetDC, but that doesnt work on this type of surface. My third attempt was to create an offscreen surface with an (A)RGB format and use StretchRect to perform the copy, but that also fails, im guessing because the required color space conversion is not supported(?), but maybe im just using the wrong destination format? I could of course manually write conversion code for all kinds of formats to RGB, but im guessing that there must be some functionality somewhere to perform this conversion? So what would be the easiest way to go about this? Btw, it is not sufficient to take a screenshot or grab the backbuffer, i need a frame of decoded video without any added black bars (because im trying to write code to remove black bars from letterboxed material :) And before someone suggest using a DirectShow filter, i already implemented that, but adding such a filter disables DXVA and causes some other problems. EDIT: Btw, i also tried D3DXSaveSurfaceToFile() [i dont want the image in the file though] and that also fails.