Board index » delphi » Anybody know anything about BMPs?

Anybody know anything about BMPs?

I'm using the folowing code to extract the bmicolors section from a bmp
file, and hold in an array [0..255] of RGBquad called coltab

TYPE  RGBQUAD = RECORD
                     rgbBlue,
                     rgbGreen,
                     rgbRed,
                     rgbReserved:BYTE;
               END;
     COLOURTABLE = ARRAY [0..255] OF RGBQUAD;

VAR f:FILE;
    rgbrec:RGBQUAD;
    coltab:COLOURTABLE;

   BEGIN(*   of load_bmp   *)
     assign(f, path);
     reset(f, 1);
     blockread(f, bmh, 14);  {  read the bitmapfileheader into bmh }
     blockread(f, bmih, 40); {  read the bitmapinfoheader into bmih }
     CASE bmih.biBitCount OF
          1               :colours:=8;   {  Check the biBitCount record}
          4               :colours:=64;  { from bmih to see how many   }
          8               :colours:=1024;{ colour records to read from }
          24              :colours:=0;   { the colour table.           }
     END;
     blockread(f, coltab, colours);  

{  This bit reads the bmicolors section of the file into coltab, which
should be in the same format. I would expect coltab to hold an exact
replica of bmicolors after this, but when I enter it into the palette
and draw stuff with it, it becomes apparant that the colours are all out
of order.}

If anybody knows anything about BMPs, or has written a unit or some code
which loads the palette up properly, I'd really appreciate it if they
would drop me a line or post here, cheers, ... I've been having nothing
but problems lately... Well, it's probably character building or
something...

Alex Noble.........................................a...@elbon.demon.co.uk
              Coming soon :          www.fatcitynews.com

 

Re:Anybody know anything about BMPs?


Quote
Alex Noble <a...@elbon.demon.co.uk> wrote:
>I'm using the folowing code to extract the bmicolors section from a bmp
>file, and hold in an array [0..255] of RGBquad called coltab

[snip]

Quote
>     CASE bmih.biBitCount OF
>          1               :colours:=8;   {  Check the biBitCount record}
>          4               :colours:=64;  { from bmih to see how many   }
>          8               :colours:=1024;{ colour records to read from }
>          24              :colours:=0;   { the colour table.           }
>     END;
>     blockread(f, coltab, colours);  
>{  This bit reads the bmicolors section of the file into coltab, which
>should be in the same format. I would expect coltab to hold an exact
>replica of bmicolors after this, but when I enter it into the palette
>and draw stuff with it, it becomes apparant that the colours are all out
>of order.}
>If anybody knows anything about BMPs, or has written a unit or some code
>which loads the palette up properly, I'd really appreciate it if they
>would drop me a line or post here, cheers, ... I've been having nothing
>but problems lately... Well, it's probably character building or
>something...
>Alex Noble.........................................a...@elbon.demon.co.uk
>              Coming soon :          www.fatcitynews.com

Unfortunately I don't have any code/units/etc. but a good advice - for
BMP handling you should get PW0775.EXE from Microsoft site,
ftp://ftp.microsoft.com/Softlib/MSLFILES/PW0775.EXE - DIB self-study
module (unfortunately in C) - great help, really. Or mail me - I'll
send it to you...

Cheers
  Dmitri

--------------------------------------------------------------
        Shit happens, but why it always happens to us?
--------------------------------------------------------------
Dmitri Poujlivyi            mailto:  dmi...@god.bel.alcatel.be
                            http://www.dma.be/p/bewoner/dmitri

Re:Anybody know anything about BMPs?


In article <vhlzyBAyNQ+xE...@elbon.demon.co.uk>, Alex Noble

Quote
<a...@elbon.demon.co.uk> wrote:
> I'm using the folowing code to extract the bmicolors section from a bmp
> file, and hold in an array [0..255] of RGBquad called coltab

> TYPE  RGBQUAD = RECORD
>                      rgbBlue,
>                      rgbGreen,
>                      rgbRed,
>                      rgbReserved:BYTE;
>                END;

an rgbquad is exactly that

record
  rgbxRed,
  rgbxGreen,
  rgbxBlue,
  rgbXwhatever:byte;
end;

incidentally if you are programming in 6-bit dac mode the pallettecomponents
will need to be shifted right by 2  ie shr 2

Quote
>      COLOURTABLE = ARRAY [0..255] OF RGBQUAD;

> VAR f:FILE;
>     rgbrec:RGBQUAD;
>     coltab:COLOURTABLE;

>    BEGIN(*   of load_bmp   *)
>      assign(f, path);
>      reset(f, 1);
>      blockread(f, bmh, 14);  {  read the bitmapfileheader into bmh }
>      blockread(f, bmih, 40); {  read the bitmapinfoheader into bmih }

incidentally not all bitmaps have a header size of 40 bytes.

Quote
>      CASE bmih.biBitCount OF
>           1               :colours:=8;   {  Check the biBitCount record}
>           4               :colours:=64;  { from bmih to see how many   }
>           8               :colours:=1024;{ colour records to read from }
>           24              :colours:=0;   { the colour table.           }
>      END;
>      blockread(f, coltab, colours);  
> Alex Noble.........................................a...@elbon.demon.co.uk

Bevyn.

--

You have reached me at an instance of temporary sanity .
Please call back later.

" when coosing between two evils.
I try the one I haven't done before " -- Mae West

Re:Anybody know anything about BMPs?


In article <bqui001-3107961205460...@uglg5.cs.auckland.ac.nz>, Bevyn
Quiding <bqui...@cs.auckland.ac.nz> writes

Quote
>incidentally if you are programming in 6-bit dac mode the pallettecomponents
>will need to be shifted right by 2  ie shr 2

Aha, that's what my problem was, it works perfectly now, cheers to all
who helped!

Alex Noble.........................................a...@elbon.demon.co.uk
              Coming soon :          www.fatcitynews.com

Other Threads