Skip to main content
GameDev.net gamedev.net
🔒 Locked

Loading resource, problem with jpegs

Started by dapeos Apr 1, 2004 at 1:09 AM 3 replies 400+ views
Original Post
dapeos
dapeos
I have been using .bmp in my game to this point. Since this is a small game (only about 10 textures) I decieded to include everything as resources, so I could have a tight packed .exe. Jpegs have much better compression so I decieded to swtitch. This an example of trying to load just one jpeg:
HGLOBAL hResource=LoadResource(g_hInst,FindResource(g_hInst,MAKEINTRESOURCE(TEXTURE_MENU),"JPEG"));

LPTSTR res= (LPTSTR) LockResource(hResource);

	D3DXCreateTextureFromFileEx(
		g_pD3Device,
		res,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		0,
		D3DFMT_A8R8G8B8,
		D3DPOOL_MANAGED,
		D3DX_FILTER_TRIANGLE,
		0,
		NULL,//color key for transparent textures

		NULL,
		NULL,
		&ptMenu);
 
Here is this texture in my .rc TEXTURE_MENU JPEG menu.jpg and in my resouce header: #define TEXTURE_MENU 500 The game compiles and runs but when it comes time to load it crashes could you please help me this is my first time working with custome resources. I am just trying to follow Jim Adams book and piece together the rest, the search is down or I wouldn't have posted this [edited by - dapeos on April 1, 2004 2:23:00 AM]
caesar4
caesar4
u r aware that JPEG is compressed and has different file headers than BMP, ur texture load function is made for BMP, so when u pass it a ptr for a JPEG, it reads what it thinks is the bitmap header, but is in fact a portion of the different jpeg header

solution: find a jpeglib, open jpeg with an open function of a jpeglib and convert it to a memory bmp, then load it as texture



Cartman''s definition of sexual harrasement:
"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"

(watch South Park, it rocks)
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
dapeos
dapeos
I wasn't aware of that thanks, could you give me a little more detail on how to do this?
It says in the SDK that D3DXCreateTextureFromFileEx() will accept
jpeg format. What am I doing wrong?
thanks

[edited by - dapeos on April 1, 2004 3:00:33 AM]
3dModelMan
3dModelMan
First be certain that "Lock" is returning a valid pointer, then use it with D3DXCreateTextureFromFileInMemory() (you''ll have to look up the args in the docs).

It does support jpeg, but I''d recommend you work with tga''s. RLE encoded tga''s are small and support alpha.

- Matt
DrunkenHyena
DrunkenHyena
You''re using D3DXCreateTextureFromFileEx which takes a pointer to a string that represents a file on disk, yet you''re passing in a pointer to data in memory. I''d crash too!


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.