Qbasicnews.com

Full Version: .bmp colors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, I need help with this. I didn't know whether to set this here or Programming help, but here it is.

It's my attempt at a .bmp loader, but the colors don't work! Try it out.

But first, make a .bmp (256, if you please) that's 320x200. save it as "pic.bmp".

Then try this code:

Code:
SCREEN 13
OPEN "PIC.BMP" FOR BINARY AS #1
C = 1: D = 1
FOR I! = 1 TO LOF(1)
   GET #1, I!, A%
   PSET (C, D), A%
   C = C + 1
   IF C > 320 THEN C = 1: D = D + 1
NEXT I!

The color should be VERY wrong. Help?
A Windows bitmap file contains a lot of information describing the dimensions, depth, etc. of the image before the pixel data. If the image is less than 16-bpp, this header also contains a palette to use -- this is how you can retrieve the correct colours (a palette is 256 RGB entries).

I have a feeling that bitmaps are stored upside down as well, for some reason... so start drawing from the bottom left. Smile

For more information about the BMP file format:

http://www.wotsit.org/download.asp?f=bmp
http://www.wotsit.org/download.asp?f=bmpfrmat

-shiftLynx
Yeah, the upside-down thing was screwing me up too, but that is easily fixed.