• ### Announcements

#### Archived

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

# i think this is a newbie question...

## 15 posts in this topic

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
0

##### Share on other sites
What you are saying is you want to go into windows programming, or you want to load a .bmp from DOS?
0

##### Share on other sites
windows (i have the dx8 sdk now, i just updated... that was a big file...)
0

##### 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
0

##### 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.
0

##### 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.
0

##### 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
0

##### 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
0

##### Share on other sites
There is no one little magical function to create a game for you. You have to do it yourself or use an API like DirectX or OpenGL.
0

##### 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...
0

##### 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.
0

##### 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
0

##### 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...
0

##### 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.
0

##### Share on other sites
thank you ... wut files would i need to include (i''m guessing windows.h)
0

##### Share on other sites
DDUtil provides the useful function DDLoadBitmap().
0