I have a bitmap with a sprite on it. Say the sprite with coordinates (0,0)-(5,4) in the bitmap coordinate space (source rectangle). I put it onto the destination rectangle with the same coordinates (0,0)-(5,4) in the render target coordinate space (ID2D1SpriteBatch::AddSprites function). But it draws the sprite with the cut right and bottom edged by one pixel.
If I use a source rectangle with (0,0)-(6,5) coordinates (that's plus one pixel), it solves the problem and Direct2D draws the sprite as needed. OK, but I do not understand why I have to use "one pixel plus" technic to draw "the uncut" sprite? What's wrong with sprite coordinates?
The D2D_RECT_F structure that you are passing to ID2D1SpriteBatch::AddSprites as the destinationRectangles is documented as:
Represents a rectangle defined by the coordinates of the upper-left corner (left, top) and the coordinates of the lower-right corner (right, bottom).
Note that you are specifying the corners on the destination device context, not the inclusive starting/ending pixel rows/columns. Therefore, if you draw from (0,0) to (0,0), you would be asking to draw a 0-sized rectangle, rather than a 1x1 rectangle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With