3

I've been writing my own library of functions to access some of the new Direct2D Windows libraries. In particular, I've been working on the ID2D1Bitmap interface. I wanted to write a function to return a pointer to the start of the bitmap data (for the editing of particular pixels, or custom encoding or whatever else I might wish for in the future). Unfortunately... problem ahead...

I can't seem to find a way to get access to the raw pixel data from the ID2D1Bitmap Interface.

Does anyone have an idea how to access this? One of my friends suggested drawing the bitmap to a surface and extracting the bitmap data from there. I don't know if this would work. It definitely seems inefficient and I wouldn't know which kind of surface to use.

Any help is appreciated. (c++ in particular, but I assume the code won't be tooo different between languages)

(I know I could just read in the data direct from the file, but I'm using the WIC decoders which means it could be in any number of indecipherable formats)

Eric Brown
  • 13,774
  • 7
  • 30
  • 71

2 Answers2

0

In general, you can't access ID2D1Bitmap data. Think of is as GPU only data. However, with some limitations you may be able to access the data using other interfaces depending on how your bitmap was created.

Since your bitmap is backed by IWICBitmap, you use Lock. [ (Bigger example: How to Modify the Pixels of a Bitmap Source) ]

If the bitmap is backed by ID3D11Texture2D you'd use a Map.

In case of IDXGISurface you can use GetDC.

vt.
  • 1,325
  • 12
  • 27
0

Since you're using the WIC decoder, you should be able to use IWICBitmap::Lock directly to get the bitmap data.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71