Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

[Easy] Direct2D - Bitmap not at correct x,y

$
0
0

Hopefully this is the right place to post. For some reason in my game, bitmaps are not being placed correctly. 

 

Here I'm trying to draw a Bitmap at 200, 200 (width is 16x16) but instead its being drawn at roughly 194, 186

 

17ff5a529854ea99f532143b9f02e49b.png

 

 

However when I try drawing it at 0,0, it draws correctly:
672e952c80ddd91d29b492281c4434ca.png
 

I pretty much followed exactly the MSDN articles, here's the code:
 

ResourceLoader::GetImageAssets().at(4);
D2D1_POINT_2F upperLeftCorner = D2D1::Point2F(200.f, 200.f);
D2D1_SIZE_F size = ResourceLoader::GetImageAssets().at(4).Bitmap->GetSize();
target->DrawBitmap(
ResourceLoader::GetImageAssets().at(4).Bitmap,
D2D1::RectF(
upperLeftCorner.x,
upperLeftCorner.y,
upperLeftCorner.x + size.width,
upperLeftCorner.y + size.height),


1.0f
);

ResourceLoader is some custom class, GetImageAssets is a vector with a class called ImageAsset, ImageAsset contains the Bitmap.

I've tried with no defined transforms and with the Matrix3x4 identity transform with still the same result. 

 

Edit: It appears that the more it strays from 0,0, the larger the "offset". It doesn't seem to be some static x,y offset/transform.

 

Edit2: Same issue with DrawRectangle. Seems to be an issue with the Direct2D drawing and not the DrawBitmap method itself.

 

Edit3: Fixed. I was not creating my HwndRenderTarget correctly.


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>