Advertisement

Displaying Hi Colour Bitmaps

Started by March 13, 2002 04:41 PM
11 comments, last by WizzardUK 22 years, 8 months ago
I''m not that far into the book yet, but I have Windows XP, and I was messing around with the programs on the CD one day...Some of them didn''t work (there was one where a robot walks around, but the robot bitmap was just a bunch of gray horizontal lines, and other programs just display a black screen.
They work just fine on a Windows 98 computer running the same version of Direct X.

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin
"I've learned something today: It doesn't matter if you're white, or if you're black...the only color that really matters is green"-Peter Griffin
you do realzie that you must run the exe from the same directory as the files. unless you are running from the ide, in which case the working directory becomes the project directory. thats a small gotacha that many newbies overlook. though your porgram should be writing a log file that mentions errors of not finding files or other errors that happen.

here is what i suggest, add soem logging functionality and see if any function calls are failing at all. also make sure that the bmp is actually being loaded and that your buffers are flipping properly if they shoudl be flipping. make sure that you are NOT using the windows functions for loading bmps. since they deal with the gdi and can cause problems sometimes if misused (the gdi is quite finiky sometimes).

i suggest loading the bmp yourself, the file format is not that difficult and i assume you understand c/c++ enough to be able to read files. you can then transfer the data yourself to the backbuffer, and rejoice you did something spiffy.

[edited by - a person on March 14, 2002 12:14:47 AM]
Advertisement
Thanks for the replies everyone.

matrix2113, the example I'', talking about are the ones after the robots. It will be the ones you say shows a black screen.

The robots can be quickly fixed.
Just replace the line
dest_ptr += (ddsd.dwWidth) ;
with
dest_ptr += (ddsd.lPitch) ;

You will find it in the ''advance pointers'' section in the Scan_Image_Bitmap function.

That will/should fix it.

a person (hmm), I know about having the images in the same directory, but even when running it from the ide it wasn''t working.
SO
I started from scratch, using an 8bit app using double buffering and page flipping as an example to keep me on the right lines, as well as LaMothes 16bit example (which didnt work on my computer) and guess what, it works!

I don''t know why LaMothes 16 bit examples don''t work, but I realised that my previous example didnt work because .......... well I forgot to convert the image from 24 bit to 16! all I had wrote was

// convert the image from 24 to 16 bit here

bloomin stupid idiot that I am!

Anyways, all is great now in 16 bit land,
Cheers for the replies everyone.
matrix2113 I hope it goes OK for you.

Wizzard

This topic is closed to new replies.

Advertisement