Windows Programming: ID2D1Bitmap Interface - Retrieving Bitmap Data
I wrote my own library of functions to access some of the newer Windows Direct2D libraries. Specifically, I was working on the ID2D1Bitmap interface. I wanted to write a function to return a pointer to the start of the bitmap data (for editing specific pixels or custom encoding or whatever else I would like in the future). Unfortunately ... the problem lies ahead ...
I cannot find a way to access the raw pixel data from the ID2D1Bitmap interface.
Does anyone have any ideas how to access this? One of my friends suggested drawing a bitmap onto a surface and extracting bitmap data from it. I don't know if this will work. It definitely seems ineffective and I don't know which surface to use.
Any help is appreciated. (C ++ in particular, but I'm guessing the code won't be dotted between languages)
(I know I can just read data directly from a file, but I use WIC decoders, which means it can be in any number of illegible formats)
a source to share
In general, you cannot access the data ID2D1Bitmap
. Think it is only GPU data. However, with some restrictions, you can access the data using other interfaces depending on how your bitmap was created.
Since your bitmap is supported IWICBitmap
, you use Lock . [ (Great example: how to change the pixels of the bitmap source) ]
If bitmap is supported ID3D11Texture2D
, you must use Map .
In case IDXGISurface
you can use GetDC .
a source to share