0

I have an issue with Direct2D when drawing bitmap while specifying source rectangle and hope someone can point me how to fix it. I am following the example from here: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_the_Direct2D_Canvas

So basically I have a custom Direct2d accelerated control to paint a 256 x 256 bitmap on it. When I just call

AcceleratedPaintPanel1.RenderTarget.DrawBitmap(FBitmapToPaint);

the result is correct, the image drawn is 256 x 256 pixels.

But it is strange when I specify source rectangle, the second image is oversized! I set the source rectangle same size as the image (256 x 256) and dont see any reason why should it be oversized. This is just a simple example with one image, but what I need to do is to get different parts from the source image and draw them separately, but all methods that use source rectangle are drawing images oversized. Thank you.

var
 D2D1RectF:TD2D1RectF;
begin
// Image 1 - properly sized image
AcceleratedPaintPanel1.RenderTarget.DrawBitmap(FBitmapToPaint); 

   D2D1RectF.left:= 256;
   D2D1RectF.top:= 0;
   D2D1RectF.right:= 512;
   D2D1RectF.bottom:= 256;

// Image 2 - oversized 
AcceleratedPaintPanel1.RenderTarget.DrawBitmap(FBitmapToPaint, @D2D1RectF);

enter image description here

serhiyiv
  • 183
  • 1
  • 2
  • 10

0 Answers0