locked
ID2D1Bitmap into IWICBitmap

    Question

  • Hello,

    I need to access to the pixel data of an ID2D1Bitmap.

    I guess it's impossible in a directly way, so I'm trying to copy the bitmap into a IWICBitmap and use Lock method to gain access to the buffer.

    I didn't find any clear documentation/steps to do that.

    Can someone help me?

    Thanks in advance.

    Walter

    Tuesday, July 3, 2012 12:17 PM

Answers

  • Hi, an ID2D1Bitmap1 inherits from ID2D1Bitmap and can be mapped into system memory, the ID2D1DeviceContext::CreateBitmap function creates an ID2D1Bitmap1 that can be used for reading back to the CPU.

    see

    ID2D1DeviceContext::CreateBitmap
    D2D1_BITMAP_OPTIONS_CPU_READ
    ID2D1Bitmap1::Map
    ID2D1Bitmap::CopyFromBitmap
    • Marked as answer by WalterAlex Wednesday, July 4, 2012 4:12 PM
    Wednesday, July 4, 2012 12:52 AM

All replies

  • Hi, an ID2D1Bitmap1 inherits from ID2D1Bitmap and can be mapped into system memory, the ID2D1DeviceContext::CreateBitmap function creates an ID2D1Bitmap1 that can be used for reading back to the CPU.

    see

    ID2D1DeviceContext::CreateBitmap
    D2D1_BITMAP_OPTIONS_CPU_READ
    ID2D1Bitmap1::Map
    ID2D1Bitmap::CopyFromBitmap
    • Marked as answer by WalterAlex Wednesday, July 4, 2012 4:12 PM
    Wednesday, July 4, 2012 12:52 AM
  • Ok I'll try it

    Thanks

    Wednesday, July 4, 2012 4:12 PM
  • Hi Walter,

    Did it work for you? I have a ID2D1Bitmap1 which I am using as off-screen target for rendering. So I cannot use D2D1_BITMAP_OPTIONS_CPU_READ option for that bitmap. Therefore I cannot access the pixels using Map. But using the following example, I am able save the ID2D1Bitmap1 through IWICImageEncoder...

    http://code.msdn.microsoft.com/windowsapps/SaveAsImageFile-68073cb0

    If IWICImageEncoder is able to access the ID2D1Bitmap1's pixels and save it, there must be a way to do it. I am just not able to figure it out.

    Saturday, July 28, 2012 4:07 AM