host: elwood
path: /usr/local/database/faq/graphic/html
file: BMP_graphic.txt

M. Braun - 10.03.00


FAQ: Conversion of Graphic Arrays to BMP-Files

Q: How can I convert a graphic data array into a windows bitmap file ? A: Let's assume, we have a data file according to the output format of an EPC recorder: This data set is organized in lines of 2048 pixels, each of them with an 8 bit value for the amplitude. The EPC recorder shows this data set as one line with 256 different grey shades. (Generation of such a data file: see epc_recorder.htm) For a conversion into a Windows bitmap, calculate the number of lines: lines = filesize / 2048 Take the file "BMP_header_300x500.bmp" as a template, copy it to a file according to your actual image size (width x height). cp BMP_header_300x500.bmp new_header.bmp This header has a fix length of 1078 bytes and contains information about the file type (Black and white, grey scale, true colour, etc...), the graphic dimensions and an optional colour table. Edit the new header and replace the numbers for the width and height, using a hex editor (e.g. mbedit). Pay attention for the byte order: Big Endian. address (hex) dimension -------------------------- 0012-0013 width 0016-0017 height (For details, see the image BMP_header.gif on this directory.) Then concatenate the modified header and the epc data set to a new BMP file. cat new_header.bmp /tmp/sccan_data.out > sidescan.bmp This must be copied to a Windows Platform (PC) and may then be viewed with any appropriate windows program (e.g. Microsoft Photo Editor, Paint, Corel Draw, etc...)