#### Archived

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

# My .bmp loader and directx class aren't working together

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

## Recommended Posts

##### Share on other sites
My #includes didn''t copy right. here they are:

include
#include
#include
#include
#include
#include

Edem Attiogbe

##### Share on other sites
Why are you trying to load the bitmaps yourself?
Let the GDI do it...sure, GDI is slow but it is fast enough for BMP loading...plus, it does all of the conversions.

Here is a snippet from my engine:

//-----------------------------------------------------------------------------//	LoadBMP("filename")//		Loads a BMP file into the tempSurface//-----------------------------------------------------------------------------GFX_BMP::LoadBMP(char *filename){	if ( ( tempSurface = DDLoadBitmap( DD, filename, 0, 0) ) == NULL )		return false;	writeLog("\nBITMAP LOADED: %s", filename);	return(1);		// Return SUCCESS}

GFX_BMP is my class.

Be sure to include the ddutil.cpp and ddutil.h file in your project.

-Coleco

~ c o l ec o ~

You stupid WANKER!

mmmmmmmmmmkay

--HASBRO SUCKS--

##### Share on other sites
I didn''t entirely follow what you were doing, but since no one
else has posted here I thought I''d chime in with few debugging
suggestions...
It looks like you haven''t totally tested out either your code that fills out a surface with a bitmap or your bmp file loader
in isolation (otherwise I presume you would have asked only
about the part that wasn''t working). Therefore, before you try
going any farther, why don''t you add some debug lines in your
color depth)as well as the first 100 bytes of the data stream to
a file. If you try loading a simple bmp with it (such as a red
and blue checkerboard) you should be able to confirm that the bmp file loader is operating properly by inspecting the header fields
and data stream by eye (that is, the data stream of a 16 bit
checkerboard image should have alternating words of one value
and then the other--DOS debug is your friend...)

In order to debug the function that fills out a surface from an
array in memory, you should make sure this actually works before
doing ANYTHING with file I/O.

Do something like:
short test_pic[10000]; //100x100x16 imagefor(i=0;i<10000;i++) test_pic = 0xaaaa; //should be grayishfor(i=200;i<400;i++) test_pic[i] = 0xffff; //should be whiteFillOutSurface(lplpDirectDrawSurface7 MySurface,(short*)test_pic, 100,100,16);

Where FillOutSurface() is the function that takes the address of
a ddrawsurface pointer and fills it with the location of a ddraw
surface initialized with the information contained in the array
you pass it.

Before I stop, I should probably add something that might actually help: if the ->Lock() call you''re making in your
FillOutSurface method still fails, (and you are SURE that it
couldn''t possibly have been locked anywhere else in your program)
then you can always actually catch the HRESULT that the Lock
function returns and do a switch case on it to see why the heck
the call is actually failing (see the dd7 sdk entry on the Lock()
method for all the error codes it can return). It might be
really informative

Hope some part of that helped.
Muse.

##### Share on other sites
Thanks Muse and Coleco. Muse, I might try the debugging round that you suggested. I was thinking of loading in a bitap through the LoadImage function, but I rather think of the code myself so that I know exactly what is going on.

Edem Attiogbe

##### Share on other sites
Also, another reason why I don''t want to use direct x to load my bitmaps is because I want to use my .bmp loading class as part of my engine, which will render primarily with OpenGL, and then Direct 3D.

Edem Attiogbe

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632651
• Total Posts
3007657
• ### Who's Online (See full list)

There are no registered users currently online

×