   SOLVED - C++ DirectX - low quality/deformed sprites
  I have loaded and drawn the following texture:http://i48.tinypic.com/262xfmv.pngHowever, it results in the following image:http://i49.tinypic.com/24vn22c.pngThis occurs even if I run the example code from tutorials. Is there something I'm missing? Here's my initialisation code:dxh::DXHANDLER::DXHANDLER(HWND& hWnd, const char* title) {dxh::clear_col = GetSysColor(COLOR_GRAYTEXT);if(FAILED(dxh::init_window(title, hWnd))) {throw std::exception("CreateWindow returned NULL.");}else {dxh::object = Direct3DCreate9(D3D_SDK_VERSION);if(!dxh::object) {throw std::exception("Direct3DCreate9 returned NULL.");}else {if(FAILED(dxh::object -> GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dxh::display_mode))) {throw std::exception("GetAdapterDisplayMode failed.");}else {D3DPRESENT_PARAMETERS pp;ZeroMemory(&pp, sizeof(pp));pp.Windowed = 1;pp.SwapEffect = D3DSWAPEFFECT_DISCARD;pp.BackBufferFormat = dxh::display_mode.Format;pp.hDeviceWindow = hWnd;pp.BackBufferWidth = 640;pp.BackBufferHeight = 480;pp.BackBufferCount = 1;pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;if(FAILED(dxh::object -> CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,  &pp, &dxh::device))) {throw std::exception("CreateDevice failed.");}else {dxh::device -> SetRenderState(D3DRS_ALPHABLENDENABLE, 1);}}}}}Sprite loading:void dxh::sprite::load(const std::string filename, int count, const char* extension) {if(!count) return;std::string strcopy;spr = 0;for(int i = 0; i < 50; ++i) texture = 0;blend = 0xFFFFFFFF;D3DXIMAGE_INFO info;ZeroMemory(&info, sizeof(info));for(int i = 0; i < count; ++i) {strcopy = filename;strcopy += stdx::chars(i);strcopy += extension;if(FAILED(D3DXCreateTextureFromFileEx(dxh::device,  strcopy.c_str(),  D3DX_DEFAULT,  D3DX_DEFAULT,  D3DX_FROM_FILE,  0,  D3DFMT_UNKNOWN,   D3DPOOL_DEFAULT,  D3DX_DEFAULT,  D3DX_DEFAULT,  0,  &info,  0,  &texture))) {MessageBox(0, ("Texture creation in instance of class \"sprite\" failed. Did you pass an invalid filename?\r\nLoading "+ strcopy).c_str(), "", 0);}}width = info.Width;height = info.Height;image_count = count;speed = 0.0f;image = 0;reset_to = 0;reset_at = count;if(FAILED(D3DXCreateSprite(dxh::device, &spr))) {MessageBoxA(0, "Sprite creation in instance of class \"sprite\" failed.", "", 0);}}Sprite drawing:void sprite::render(D3DXVECTOR3 position) {image += speed;if(image >= reset_at) image = (float)reset_to;spr -> Begin(D3DXSPRITE_ALPHABLEND);spr -> Draw(texture[(int)image], 0, 0, &position, blend);spr -> End();}Here's a link to the full Visual C++ project:http://host-a.net/PlasticineGuy/dxhandlertext.zip[Edited by - PlasticineGuy on April 7, 2010 5:42:32 AM]
  It seems that the image dimensions are not a power of two (24x24). Some video cards don't support that, so D3DXCreateTextureFromFileEx() will resize the image to the nearest power of two, in this case 32x32.You could try resizing the image yourself in a paint program (it might do it better than D3DX), but since the image is at such a low resolution, I'm not sure how much it would help.Just to test this, try using a larger image (something like 256x256) and see if this still happens.   ;  Um... yep. Can't believe I missed that. Thank you!   