Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DirectX texture loading, texture gets resized

24 views
Skip to first unread message

Marcel Overweel

unread,
Sep 17, 2009, 9:05:29 AM9/17/09
to
Hi all,

I was having problems with pixel-perfect collision detection...
(Oh no, not another pixel-perfect question! I hear you scream.)

.. and I solved it.
(you see, you didn't need to worry :))

But I don't understand why something is happening.

Using: .NET, C#
Microsoft.DirectX.Direct3D.Texture and
Microsoft.DirectX.Direct3D.Sprite

I have a windowed direct3d surface, 1024x768, 4 bytes per pixel

I load a texture from a smaller bmp which is 640x640 in size.
This bitmap contains blocks with sprite images.

I tried to do pixel checking against a background image using
LockRectangle and a double x/y loop, but somehow every sprite
got mangled. It seemed like no pixel was were it should be
except for the pixels on the first scanline.

The pixel tests on the background bitmap didn't have that problem.
Width=1024, 4 bytes per pixel, so each scanline was 4096 bytes.

Now it seems that the 640x640 bitmap is resized (not scaled) to
1024 by something. And because the background bitmap had the
exact same size as the device, at first, I didn't see that anything
could be wrong with the algorithm.

I guess this resized texture will take up more memory than is required.
Can this resizing 'feature' be turned off?
I've looked into the parameters of the sprite, texture and the
TextureLoader.LoadFromFile method, but I can't find anything to
change this behaviour.

And why is it happening in the first place?

regards,
Marcel


Marcel Overweel

unread,
Sep 18, 2009, 7:10:49 AM9/18/09
to

"Marcel Overweel" <move...@gonen.nl> schreef in bericht
news:4ab23419$0$83241$e4fe...@news.xs4all.nl...

Hehe, got it.
Textures get resized to a power of 2.
So 640 x 640 gets 1024 x 1024.
Have the original sprite bitmap resized to 512 x 512 and it stays 512.
I guess the reason for directx is some form of optimizations.

regards,
Marcel


0 new messages