0

I am using DirectComposition in conjunction with DirectManipulation to render things. I have some text present on the DirectCompositionVisuals which are chained vertically. I want to pull the pixel data of the selection so that I can do stuff with it. I am trying to do the following but this however results in surface getting cleared

HRESULT hr = DCSurface->BeginDraw(&rect, IID_PPV_ARGS(&dxSurface), &point);
HDC hdcSurface = nullptr;
hr = dxSurface->GetDC(FALSE, &hdcSurface);

Illuminati
  • 111
  • 7

1 Answers1

0

As far as I'm concerned, first, you should create an updateable surface object that can be associated with one or more visuals for composition via IDCompositionDevice::CreateSurface method. And then use the IDCompositionSurface::BeginDraw method to initialize the surface with pixel data.

Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20
  • thanks for your response. I have the visuals and their surfaces working fine. I am able to apply transform as well efficiently. The problem comes when I go in to get the pixel data from the surface. Since the BeginDraw needs rect, it flushes out everything to black. Not sure what is wrong – Illuminati Jul 13 '23 at 10:28
  • If the surface is not a virtual surface, then the first time the application calls this method for a particular non-virtual surface, the update rectangle must cover the entire surface, either by specifying the full surface in the requested update rectangle, or by specifying `NULL` as the updateRectangle parameter. – Jeaninez - MSFT Jul 14 '23 at 07:30
  • Yes As I mentioned earlier my intention is not to draw but to get the pixel data for already drawn content. That is why i am sending the rect to be picked up – Illuminati Jul 14 '23 at 11:46
  • For virtual surfaces, the first call may be any sub-rectangle of the surface. You could try to create a virtual surfaces via`IDCompositionSurfaceFactory::CreateVirtualSurface`. – Jeaninez - MSFT Jul 17 '23 at 06:12