Re: DirectX texture loading, texture gets resized

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Marcel Overweel" <moverweel@xxxxxxxx> schreef in bericht
news:4ab23419$0$83241$e4fe514c@xxxxxxxxxxxxxxxxx
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


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


.



Relevant Pages

  • =?iso-8859-1?Q?Re:_CopyFromScreen_Bitmap_als_Bild_speichern_und_Gr=F6=DFe?= =?iso-8859&#
    ... wenn du mit der Auflösung festlegst, dass in einem Zoll 96 Pixel darzustellen sind, dann belegen 200 Pixel etwa 55 mm. ... Dim bmp As Bitmap = New Bitmap ... g.DrawImage(bmp, 0, 0, breite, hoehe) ... Wie Du erkennen kannst ist die Linke Grafik nur noch halb so breit wie die Obere, ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: count colors in bitmap
    ... But on my own two machines your code DOES crash on a 1024 x 768 bitmap! ... And it also DOES crashes on a 3200 x 2400 pixel bitmap. ... Why don't you just believe me, and check things out further yourself, perhaps on the machines of other people you might know, specifically on machines that might be differently configured and running different vesions of the OS than your own. ... Private Declare Function LoadImage Lib "user32" Alias _ ...
    (microsoft.public.vb.general.discussion)
  • Re: count colors in bitmap
    ... But on my own two machines your code DOES crash on a 1024 x 768 bitmap! ... And it also DOES crashes on a 3200 x 2400 pixel bitmap. ... on both of my own machines your app CRASHES on both a 1024 x 768 bitmap and on a 3200 x 2400 pixel bitmap. ... Private Declare Function LoadImage Lib "user32" Alias _ ...
    (microsoft.public.vb.general.discussion)
  • Re: count colors in bitmap
    ... But on my own two machines your code DOES crash on a 1024 x 768 bitmap! ... And it also DOES crashes on a 3200 x 2400 pixel bitmap. ... Private Declare Function LoadImage Lib "user32" Alias _ ...
    (microsoft.public.vb.general.discussion)
  • Re: VB3 is making my head spin!
    ... > and displaying it pixel by pixel] tell me how. ... compressed bitmap from an original 24 but full colour bitmap that is held on disk as a standard ... It shows you how to load a full colour 24bit .bmp file from disk and count ... Dim z As Long, t1 As Long, t2 As Long ...
    (comp.lang.basic.visual.misc)