Skip to main content
gamedev.net
🔒 Locked

Bitmap Templates

Started by hoogie Oct 29, 2004 at 4:15 AM 2 replies 600+ views
Original Post
hoogie
hoogie
Hi, I am working on creating a basic 2D sprtie based engine in DirectX 9 and I am currently happily loading sprite textures via the D3DXCreateSprite() and D3DXCreateTextureFromFile() functions. My problem is that I am finding it very hard to find standard sprite texture files and can only find templated graphics, my question is exactly how do you load from a template? The files usually have over 100 graphics, how do you select them individually? Thanks
Drazgal
Drazgal
Assuming you load the texture into a ID3DX::Sprite when yuo draw you set the source rect (the second param in the draw call) to the area on the sprite you want to draw.

For example if you have a 64*64 texture with 4 32*32 sprites

0,0,32,32 (rect for first sprite)
32,0,32,32 (rect for second sprite)
0,32,32,32 (rect for third sprite)
32,32,32,32 (rect for the fourth sprite)

You then use the source rectangle you want!

hoogie
hoogie
I take it you meen :

0,0,32,32
32,0,64,32
0,32,32,64
23,32,64,64

?

Im currently trying it out and the selection is definitely working except not picking the correct sprites, even after opening the file in paint and making a note of coordinates it selects the wrong area, is thid due to paint?

Cheers
hoogie
hoogie
Hey,

I am having real trouble sorting out some problems. Basically if I try to load a texture file (.tga) containing one graphic and set the dimension to be from 0, 0 to whatever the size of the file then it loads fine with no problems.
However when loading from a bitmap (.bmp) template the loading is never correct as the image displayed is never alligned to the image in the template, it also always seams to load the wrong part of image and on top of that it also displays the black from the backround which should be see through.

Does anyone have any ideas why I might be getting these probelms? Or any advise on how to resolve it?

Thanks for any help

Topic Locked

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

Sign in to reply to this topic.