Hi I am having great trouble with making my bitmap fit properly on a 1024x768 full screen window. The length is correct but the vertical is too long. I have searched the net and it has said that the size goes up in squares eg 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024

but as 768 is not a square, it gets resized up to 1024, the closest size. This completely stuffs up my bitmap because it goes off screen.

i devided it into 3 vertically, which makes each bitmap 256 pixels high. (a square, so it worked) but i find this a real silly way having to make 3 bitmaps just for 1. I know there must be an easier way. Please help

You may get better responses to DirectX specific questions in the Game Development forum, or in the XNA forums (it's mostly centered on using the XNA tools with C#, but there are some forums on DirectX, and I do believe it's supposed to be the official DirectX forum).

As to your problem, screen sizes are not perfect squares. The only real rule is that the ratio of width to height should be 4:3, or 16:9 for widescreen (and that the numbers are integers). So, if 1024 is your width, using algebra:

4:3 = 1024:height

1024*3 = 4*height

1024*0.75 = height = 768.

I'm not sure exactly what you're looking for, if that wasn't it. Some code would help.

sorry i didn't see the other section i'm new:$

that sounds like a good answer but when i set the bitmap to 1024 by 768 it goes to 1024x1024 for some reason.

code:(this is on full screen 1024x768-the bitmap should full the whole screen perfectly).

LPDIRECT3D9 pD3D = NULL;
LPDIRECT3DDEVICE9 pd3dDevice = NULL;

LPDIRECT3DTEXTURE9 menupic;
LPD3DXSPRITE pd3dspt;    // the pointer to our Direct3D Sprite interface

D3DXCreateTextureFromFileEx(pd3dDevice,    // the device pointer
                            "res/menu/menu.bmp",    // the new file name
                            1024,    // width
                            768,    //  height -rounds to 1024
                            D3DX_DEFAULT,    // no mip mapping
                            NULL,    // regular usage
                            D3DFMT_A8R8G8B8,    // 32-bit pixels with alpha
                            D3DPOOL_MANAGED,    // typical memory handling
                            D3DX_DEFAULT,    // no filtering
                            D3DX_DEFAULT,    // no mip filtering
                            D3DCOLOR_XRGB(200, 0, 200),    // color key
                            NULL,    // no image info struct
                            NULL,    // not using 256 colors
                            &menupic);    // menu picture sprite


pd3dspt->Begin(D3DXSPRITE_ALPHABLEND);    // begin sprite drawing

D3DXVECTOR3 menu_center(0.0f, 0.0f, 0.0f);    // center at the upper-left corner
D3DXVECTOR3 menu_position(0.0f,0.0f,0.0f);    // position at 50, 50 with no depth
        
pd3dspt->Draw(menupic, NULL, &menu_center, &menu_position, D3DCOLOR_ARGB(255, 255, 255, 255));

pd3dspt->End();    // end sprite drawing

Oh, I see what you mean about powers of two (I thought you meant that screen sizes could only be powers of two). I believe I've loaded images whose width/height weren't powers of two, but I don't remember off hand exactly how I did it. I'll see if I can dig up the code can get back to you. You could also research this a bit: D3DX_DEFAULT_NONPOW2. That might help you out.

WOW THANKS I Cant wait for you to get back to me! :) i will search that up in the mean time.

EDIT: Searched D3DX_DEFAULT_NONPOW2 up and i put it in instead of the default but it didnt change anything. I cant make it a power of two size because 1024 is too big and 512 is too big. Hope you find how you did it.

Trying using surfaces instead of textures. link I believe that surfaces are supposed to be used for backgrounds, like the one you're using, and textures should be used for sprites, which often do have widths and heights that are powers of two.

commented: Good advice! +8

thanks :) could you give me a small example? i'm finding it quite hard to get it working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.