I'm trying to load compressed images to a sprite object with C++,
using a LPD3DXSPRITE and the D3DXCreateTextureFromFileEx() function
to load it and of course D3DXGetImageInfoFromFile() to get some info,
but I don't know how to go about it.

How do I decompress them before loading them to memory and then to sprite?
Can I load images using another method, one which I have yet to discover?

This should be possible, maybe I'm going about this the wrong way.
I remember Warcraft3 have some .mpq files, which, I'm guessing, also
are compressed images as well as models, and they obviously knew
how to do this. :P

LPDIRECT3D9 d3d = NULL;
D3DPRESENT_PARAMETERS d3dpp;
LPDIRECT3DDEVICE9 d3ddev;
LPD3DXSPRITE spr;
D3DXIMAGE_INFO img_info;
LPDIRECT3DTEXTURE9 texture;
HWND hWnd;

void LoadD3D(){
	if(FAILED(d3d = Direct3DCreate9(D3D_SDK_VERSION))){
		MessageBox(NULL, "Failed to create D3D interface. Possible cause(s): Resolution; wrong window dimensions", "Error", MB_OK);
        PostQuitMessage(0);
    }

	ZeroMemory(&d3dpp, sizeof(d3dpp));

	d3dpp.BackBufferCount = 1;
	d3dpp.BackBufferWidth = GetSystemMetrics(SM_CXSCREEN);
	d3dpp.BackBufferHeight = GetSystemMetrics(SM_CYSCREEN);
	d3dpp.hDeviceWindow = hWnd;
	d3dpp.Windowed = FALSE;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;

	if(FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT,
                                D3DDEVTYPE_HAL,
                                GetGameWindow()->Handle(),
                                D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                &d3dpp,
                                &d3ddev)))
    {
        MessageBox(NULL, "Failed to create a D3D device.", "Error", MB_OK);
        PostQuitMessage(0);
    }

	d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50,50,50));
	d3ddev->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);

	if(FAILED(D3DXCreateSprite(d3ddev, &d3dspt))){
		MessageBox(NULL, "Failed to create a sprite interface.", "Error", MB_OK);
		PostQuitMessage(0);
	}
        LoadExample();
}

void LoadExample()
{
	ZeroMemory(img_info, sizeof(D3DXIMAGE_INFO));

	D3DXGetImageInfoFromFile("sometexture.png", img_info);

	D3DXCreateTextureFromFileEx(d3ddev, 
				    "sometexture.png", 
				    img_info->Width, 
				    img_info->Height,
				    img_info->MipLevels, 
				    NULL, 
				    D3DFMT_A8R8G8B8, 
				    D3DPOOL_MANAGED, 
				    D3DX_DEFAULT, 
				    D3DX_DEFAULT, 
				    D3DCOLOR_XRGB(255,0,255),
				    img_info,
				    NULL,
				    texture);
}

void DrawThatShit(){
	RECT rc;
	SetRect(&rc, 0,0,img_info->Width, img_info->Height);
	d3ddev->BeginScene();
	d3dspt->Begin(D3DXSPRITE_ALPHABLEND);
	d3dspt->Draw(texture, &rc, NULL, &D3DXVECTOR3(0,0,0), D3DCOLOR_XRGB(255,255,255));
	d3dspt->End();
	d3ddev->EndScene();
}

Am I posting in the wrong section, or do you guys don't have an answer for this? :S

Patience, young Luke. I'm not a D3D expert, but there probably are a couple around here somewhere. They might not get back to you on the weekend.

While I know next-to-nothing about this, I'd like to think that the functions that load a compressed image would uncompress it as part of the loading process....

Yes, no doubt someone knows about this, but to further explain what I'm trying to do:

  1. Extract image from a compressed image archive (I call mine .ssc, compressed with the Deflate algorithm)
  2. Load to sprite object(s)
  3. Draw
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.