Archived

This topic is now archived and is closed to further replies.

This topic is 5241 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

hey guys yet another question, I''m trying to write a function that reads a file or resource bitmap and copies it to an image surface, i have the file part working, but i''m having trouble getting the resource file part to load. I''m using the D3DX functions. I not sure how to refer to the resource and also how to i get the dimensions of the resource, thanks: int cSurface::CreateImageSurface(char * filename, cDirectX * directX, int location) { HRESULT result; fstream BitmapInfo; BitmapInfo.open (filename, ios::binary | ios::in); if (BitmapInfo.is_open ()) { /* Ignore 18 bytes */ <---only works for file mode BitmapInfo.seekg (18, ios::cur); /* Get width and height of bitmap */ BitmapInfo.read ((char *)&Width, sizeof (int)); BitmapInfo.read ((char *)&Height, sizeof (int)); } result = directX->g_pd3dDevice->CreateOffscreenPlainSurface(Width, Height, directX->d3dpp.BackBufferFormat, D3DPOOL_DEFAULT,&Surface,NULL); if(FAILED(result)) return 0; if(location) /*load from file*/ result = D3DXLoadSurfaceFromFile(Surface, NULL, NULL, filename, NULL,D3DX_DEFAULT,0,NULL); else /*load from resource*/ result = D3DXLoadSurfaceFromResource <--- not working (Surface,NULL,NULL,NULL,filename,NULL,D3DX_DEFAULT,0,NULL); if(FAILED(result)) return 0; return 1; }

.lick

Share on other sites
You gotta use LoadSomethinfFromResourceEx(..) with the parameters you''d have used with ...FromFileEx().
Check DXSDK help files for the list of params and know that instead of the name of the file/resource you''ll have to write MAKEINTRESOURCE(IDR_MYRESOURCE). MAKEINTRESOURCE is a macro you can also use in plain windows programmnig, I ve been loking for long before being able to understand how it works. One more thing though, amongst the params, you''ll be asked for a module handle. Since your program looks way simple, I think the module you use is the one normally given by Windows, so simply specify null for this.
//for example, this workshr = D3DXLoadSurfaceFromResource(m_pBoardPattern,0,0,0,	MAKEINTRESOURCE(IDB_BACKGROUND),0,D3DX_DEFAULT,0,null);//dont forget to search in the documentation to understand what each parameter is

Voila. Hope Ive been useful.

Prog, Hex & Rock''n''Roll :
I don''t like the Prog but the Prog likes me.
Some nice poetry to sweeten your spirit and relax a bit before programming

Share on other sites
i tried using the makeintresource file but the compiler is not finding my resource IMG_BITMAP, which is defined in my *.rc file like this: IMG_BITMAP BITMAP image_black.bmp

When I compile I see that the executable is larger, but how come the makeintresource does not find it???? thanks.

shameless bump

Share on other sites
Is your IMG_BITMAP defined somewhere differently?

MAKEINTRESOURCE = Make integer from resource id.

It doesn''t work real well when your ID is defined with a different number.

ie if your IMG_BITMAP is 101 in your resource file, and it''s defined as 102 in your resource.h, it''s not going to load

Share on other sites
thanks guys, i figured it out

• Forum Statistics

• Total Topics
628698
• Total Posts
2984275

• 20
• 10
• 13
• 13
• 11