Author Topic: 24 bit bitmap question  (Read 4352 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
24 bit bitmap question
« on: October 15, 2007 »
In a lot of recent intros, there have been some really great logos that were downgraded to 256 colour indexed palettes, I have been exploring 24 bit bitmaps a little and here is what I understand about them.

They are stored upside down.
Each pixel has three bytes hence 24 bit colour
The bytes are specified in Blue , Green , Red order.
The bitmap contains a header with information such as file size etc.

What I would like to be able to do is to use 24 bit bitmaps and I thought to convert the 24 bit bitmap straight into a .bas file using bin2bas.

I did this and wasn't too horrified to see a 1.7mb file! Meh :) anyway it will crunch down small..

The header as far as I can tell contains a lot of information that I do not need.
All I want are those rgb values so if somebody could tell me how to calculate where the header stops I would be really grateful.

If anything, it should be easier to use 24 bit bitmap images than 8 bit ones.

Thanks.

Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 24 bit bitmap question
« Reply #1 on: October 15, 2007 »
I think that the colours start 55 bytes into the file... I am not sure...
Shockwave ^ Codigos
Challenge Trophies Won:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: 24 bit bitmap question
« Reply #2 on: October 15, 2007 »
The description of the Windows BMP file format can be found here: http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html

Although it's a simple format, it's too Windows-dependent for my taste. A lot of information contained in the header is really useless for your purpose.

I strongly suggest that you use the Targa file format, which is much simpler and also stable (no new variations with every new Windows release).

I have attached the Targa file format specs. All the image manipulation software can handle it. It supports 24bits as well as 32bit (24bit RGB and 8bit alpha) in a format that is proper for display.

A few lines of code in any language will give you results, quickly
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 24 bit bitmap question
« Reply #3 on: October 15, 2007 »
I specifically want to understand where the pixel data starts in a 24 bit bitmap Stormbringer so please let my question stand, thanks :) Any help on finding where the pixel data starts in 24 bit windows bitmap pictures would be gratefully accepted!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 24 bit bitmap question
« Reply #4 on: October 15, 2007 »
It's ok now I worked it out :)

I will tidy up the source and post it later for others.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: 24 bit bitmap question
« Reply #5 on: October 15, 2007 »
Look up BITMAPFILEHEADER on MSDN, then, 10 bytes in, there's a 32bit offset to the actual bits counting from the beginning of the file.
http://msdn2.microsoft.com/en-us/library/ms532321.aspx
If you use MS Paint to save .bmp, then the files are often not compressed and there will be width*height worth of pixels, but that's not always the case - there are various methods of compression.

Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 24 bit bitmap question
« Reply #6 on: October 15, 2007 »
Yep, I've assumed no compression. The solution I have is a little bit messy at the moment bit it will soon work well enough for others to use :)

Cheers Jim :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: 24 bit bitmap question
« Reply #7 on: October 15, 2007 »
ok.. ok... hehe.. watch out as rows in a BMP file are stored as 4-byte boundaries. So if your image width*bytes per pixel is not a multiple of 4 bytes, then you have extra padding bytes at the end of each row..
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 24 bit bitmap question
« Reply #8 on: October 15, 2007 »
Yep, I worked that out mate :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: 24 bit bitmap question
« Reply #9 on: October 15, 2007 »
@Shockwave: Take a look on this thread, there's a fine example for loading 32 bits image by Jim and I have showed a way to load them from resource exe file.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 24 bit bitmap question
« Reply #10 on: October 16, 2007 »
Hehe, if only I had seen that Rbraz :) I made my own solution and posted it though. Anyway, than you for the help!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: 24 bit bitmap question
« Reply #11 on: October 16, 2007 »
More code here for http://dbfinteractive.com/index.php?topic=2334.0 loading other formats.

Jim
Challenge Trophies Won: