On Sat, 12 Jul 2003 08:49:49 +0100, Dilwyn Jones <[EMAIL PROTECTED]> wrote:



Phoebus Dokos wrote:


You could also get BMP2SCR from Malcolm and use it in reverse
(trivial to
do so and from the quick look I gave to your code you're on the
right
track).
Just had a quick look (it's on disk GE104 in my PD library) . However,
it doesn't explain the file structure except how to check it's 24 bit
and picture size. But it does show how to do the approximation of 24
bit colour to 16 bit QL colour (i.e. how to convert 8 bit RGB
component to 5 or 6 bit GD2 colour components - simply lop off the
extra info, you then simply get coarser steps of colour, so instead of
values 0-31 for a bit GD2 colour you get 0-255 step 8 in 24-bit
colour). A bit mind bending for a simpleton like me, but I'll get
there ;-)
<snip>


The complete file format ('new' format which is the most common) (more like the complete header of the BMP format is as follows):

Offset Field Size Contents
000h Id 2 bytes (Insert here 'BM' for BMP image file. Other options are possible as well)
002h FSIZE 4 bytes Full file size in bytes
006h RESVD 4 bytes Reserved (Pad with 0s)
00Ah BMPD_OFF 4 bytes Offset of the beginning of bmp data from the beginning of file
00Eh BMPH_SZ 4 bytes Length of the BMP Info Header (what describes bmp colours, compression... possible sizes are:28h - Windows, 0Ch OS2 1.x, F0h OS 2.x
012h WD 4 bytes Width of image in pixels
016h HT 4 bytes Height of image in pixels
01Ah PL 2 bytes # planes in the picture (not the flying kind ;-)
01Ch BPP 2 bytes BPP used for palette info. (Possible colours of sorts). Possible values
1 - Mono, 4 - 16 colours, 8 - 256 colours, 16 - High colour, 24 - 24 bit colour, 32 - 32 bit colour
01Eh CMP_SPEC 4 bytes Compression Specs. Possible values: 0 - none (Also BI_RGB), 1 - RLE 4bit/pixel (Also BI_RLE4), 2 - RLE 8bit/pixel (Also BI_RLE8), 3 - Bitfields (Also BI_BITFIELDS)
022h BMP_DSZ 4 bytes Size of the bitmap DATA in bytes. Must be rounded to the next 4 byte boundary.
026h HRES 4 bytes Horizontal res in pixels/meter
02Ah VRES 4 bytes Vertical res in pixels/meter
02Eh COL 4 bytes Number of colours used by this bitmap (ie for an 8bit colour image: 256)
032h IMPCOL 4 bytes Number of important colours (equal to COL above if every colour is important)
036h PAL n*4 bytes Palette Specs. For every entry in the palette, 4 bytes describe the RGB values as follows: 1 byte:blue, 1 byte: green, 1 byte red, 1 byte filler (filled with 0)
436h BMP_DATA n bytes Depending on CMP_SPEC, all bitmap data bytes that represent indices in colour palette



Now since a Type structure is impossible in SBasic, you should use an Array to conveniently manipulate all this blah-blah.
However to save space you should remember that there is a MAXIMUM size of the header (and that occurs when a palette exists).


Also to try to go through the hoops and produce every possible combination would be irrational (IMVHO) and I would recommend you use only the 24bit option, as it simplifies calculations. Not to mention that you can have the rest of the info hard coded for all screen sizes mode 32 and 33 support.
Moreover, in Mode 33 (and you should include Mode 33), remember the importance of the Intensity (Extra Green bit) and cater for that in the translation.


Hope this helped a bit,


Phoebus




--
Phoebus Dokos - Undergrad in MIS
Eberly College of Business - Indiana U. of PA




Reply via email to