Search code examples
c++oop2ddirect2d

Creating an bitmap atlas with direct2d, what does "current bitmap" refer to?


So I am trying to get bitmaps from an atlas with direct2d. This is the only method I have to that maybe does what I want but... what does the current bitmap refer to? If I understand this well, this doesn't copy and area from a bitmap into another bitmap right?

virtual HRESULT CopyFromBitmap(
  [in, optional]  const D2D1_POINT_2U *destPoint,
  [in]            ID2D1Bitmap *bitmap,
  [in, optional]  const D2D1_RECT_U *srcRect
) = 0;

destPoint [in, optional]

Type: const D2D1_POINT_2U*

In the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.

bitmap [in]

Type: ID2D1Bitmap*

The bitmap to copy from.

srcRect [in, optional]

Type: const D2D1_RECT_U*

The area of bitmap to copy


Solution

  • CopyFromBitmap() is a method on the ID2D1Bitmap interface, so it implies that you have a bitmap already, which is the object that calls the copy function. Something like this ...

    ID2D1Bitmap *pSourceBitmap = 0;
    ID2D1Bitmap *pDestinationBitmap = 0;
    
    // some initialisation of the above bitmaps goes here ...
    
    // copy a region from source to destination
    pDestinationBitmap->CopyFromBitmap(/*point you want to copy to*/, pSourceBitmap, 
        /*rect to copy from*/);