Author Topic: BMP2Raw Colour Problem  (Read 6200 times)

0 Members and 1 Guest are viewing this topic.

Offline Storm Trooper

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
BMP2Raw Colour Problem
« on: July 01, 2011 »
Hope you dont mind asking  this in your post. I know there's rbz's bmp2raw, this is a curiosity request. Have got the palette part with adding and andy in the shifting for r g b as ubytes.

Can't get the RAW data working though, i've made it come out as 00-FF but the values doesn't match up with the 256 / 8 bit bmp.

I forgot to bring the sauce with me, it would be nice to make it gen like. palette in ubyte's just red grn blu and the raw &h00 - &hff. Do you know how and thank you.


[Topic Split from Bload topic by Shockwave ~ Please start a new thread if your question is different.  Thanks.]
« Last Edit: July 01, 2011 by Shockwave »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: BMP2Raw Colour Problem
« Reply #1 on: July 01, 2011 »
It's not really clear what you're asking.  But I'll take a punt...:)

The palette in the raw file will be 768 bytes (256 colours x 3 bytes) followed by 640x480 pixels.
So, for each byte of the pixels, look up the rgb colour in the palette and use that.  Depending how you have things set up, that would look like
Code: [Select]
pixel = pixels[x*y]
colour = (palette[pixel*3] Shl 16) + (palette[pixel*3+1] Shl 8) + (palette[pixel*3+2])
That assumes that both your palette and pixels arrays are unsigned chars/bytes.
You can pre-compute the rgb colours from the palette into 32bit values for more speed once you get it working.

Is that any help?

Jim
« Last Edit: July 02, 2011 by Jim »
Challenge Trophies Won:

Offline Storm Trooper

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
Re: BMP2Raw Colour Problem
« Reply #2 on: July 02, 2011 »
many thanks Jim. it's the code that relsoft kindly posted in the emulate bload thread.
Im interested with the ubytes, as it seems to make smaller exes.

if you look at how rbz's bmp2raw / bin2bas files are done, there is a raw bas file made up with &h00 - &hff, i've heard it called palette indexing. I cant get the raw information to match up and save properly. I also don't know where and how that is stored, to get at it.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: BMP2Raw Colour Problem
« Reply #3 on: July 02, 2011 »
I'm also not sure about what you are looking for, my guess is that you are trying to use the output (pal/raw) of bmp2raw inside this relsoft's converter and use freebasic gfxlib commands to display an image?
It's not possible because fb graphics library uses a different internal format.

...
Im interested with the ubytes, as it seems to make smaller exes.
...
Imho, don't waste your time trying to make things smaller for now, this is something you could do when you got more coding experience.
For now just try make things work nicely and look pretty with good design (talking about democoding), which is already a lot of work when we are newbie.

Challenge Trophies Won:

Offline Storm Trooper

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
Re: BMP2Raw Colour Problem
« Reply #4 on: July 02, 2011 »
Im not after a gfx lib thing at all. I'm one of the tinyptc_ext fans.
I really like the tools bmp2raw, I was trying to work out how you pulled off and made it save the RAW file as 00-FF

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: BMP2Raw Colour Problem
« Reply #5 on: July 02, 2011 »
The seperate bytes that make up the rgb components of the palette are stored within the colour table section of bitmaps with 8 bitplanes or less.

The image data references these bytes to re-create the image.

RBZ's tool seperates the palette and image data into two arrays of ubytes, it's damned useful but not witchcraft.

There's masses and masses of stuff about the bitmap file format out there and it's pretty easy to follow.

Google is your friend!
Shockwave ^ Codigos
Challenge Trophies Won: