Qbasicnews.com
September 27, 2020, 03:11:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: .bmp colors  (Read 2147 times)
j2krei08
Guru
**
Posts: 284



WWW
« on: April 05, 2005, 04:08:23 PM »

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?
Logged
shiftLynx
Wandering Guru
***
Posts: 340



WWW
« Reply #1 on: April 05, 2005, 04:20:25 PM »

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. Smiley

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
Logged

img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
j2krei08
Guru
**
Posts: 284



WWW
« Reply #2 on: April 06, 2005, 09:39:31 AM »

Yeah, the upside-down thing was screwing me up too, but that is easily fixed.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!