Archived

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

i think this is a newbie question...

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, i have been learning c++ for 4 years now and have been writing dos text-based programs... but, i got sick and tired of that, but i hadn''t found any books on loading bitmap files... i just want to load it to an offscreen surface so that i can use the RECT type to use them in a tile based game... what is the simplest way to load a bitmap to an offscreen surface? (could you explain how to do it either to load directly from a file instead of a rescource file?) thank you, ur help is very appreciated

Share this post


Link to post
Share on other sites
If I remember rightly, there is some example code of how to do this in the sdk. The file with the bmp loader is called something like ddutil.cpp at least that was the name in the dx7 sdk.
Anyway, I suggest that you look in the examples as the sdk''s tend to have a lot of quite easily understandable code.
Regards,
Devore

Share this post


Link to post
Share on other sites
If you are needing help of this kind you need to get started from the ground up. I suggest that you get a good book on the subject such as "The Zen of Direct3D Programming" which also covers lots of 2D stuff similar to what you want to do.

Share this post


Link to post
Share on other sites
I''d suggest you learn the Win32 API first. Try Programming Windows by Charles Petzold or Windows 98 Programming from the Ground Up by Herbert Schildt. After that, if you want to learn DirectX, I would suggest Tricks of the Windows Game Programming Gurus by André LaMothe.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
is there any way to do it with 1 function, or just smaller? could i have some code that inserts a bmp file called "grass.bmp" with 32x15 dimensions... it is for an isometric game.. and if possible, some tiling code

Share this post


Link to post
Share on other sites
is there any way to do it with 1 function, or just smaller? could i have some code that inserts a bmp file called "grass.bmp" with 32x15 dimensions... it is for an isometric game.. and if possible, some tiling code

Share this post


Link to post
Share on other sites
i know that... i just want a DirectDraw function that displays a *.bmp file... i know that there is one, but i get a little lost when i go through the huge header files in the sdk...

Share this post


Link to post
Share on other sites
Based on what you said that you were writing text-based applications, I assume you don''t know DirectX. You can''t use a DirectDraw function without actually going through all the initialization and such. There is Blt(), but you can''t just throw it in the middle of your code and expect it to work. You have to initialize DirectDraw and stuff. You''ll also need to write your own bitmap loader, or you could use LoadBitmap() from the Win32 API.

Share this post


Link to post
Share on other sites
www.winprog.org

they have some easy to comprehend tutorials.

"I''''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''''Urden

Share this post


Link to post
Share on other sites
so, that must be why the code is always so long... i have seen a couple examples that are long (most were long to free the memory after the program is closed), and a lot of stuff about "HBITMAP" and "BITMAP" classes... a also heard about "LOADFROMFILE" that could be put into the declaration of the LoadImage() function from the ddraw.h file, but i''m never told where the filename should go...

Share this post


Link to post
Share on other sites
LoadImage is from the Win32 API, not from DirectDraw. It is defined as:

HANDLE LoadImage(
HINSTANCE hinst,
LPCTSTR lpszName,
UINT uType,
int cxDesired,
int cyDesired,
UINT fuLoad
);


hinst is the instance handle to your application. It is passed to WinMain when the program starts. lpszName is where you either specify the name of the resource, or in your case, the filename. uType is the type of image to load. Use IMAGE_BITMAP here. cxDesired and cyDesired is the dimensions you want the bitmap to be loaded in, use 0 if you want the bitmap to retain its normal size. fuLoad should be LR_LOADFROMFILE if you want to load from a file, but it can be a combination of other flags as well. The function returns an HBITMAP which you can blit to a surface.

Share this post


Link to post
Share on other sites