![]() |
IET | ![]() |
|
search :
help :
home
|
||
|
Latest News:
|
|
|


|
Topic Title: decoding monochrome bitmap files Topic Summary: problem in decoding raw data from bitmap files for output Created On: 25 January 2012 12:34 PM Status: Post and Reply |
Linear : Threading : Single : Branch |
Search Topic |
Topic Tools
|
|
|
|
|
Hi all,
I was wondering if anybody has knowledge of how to decode monochrome bitmap files? ie how the raw data is formatted and how i could convert to binary? many thanks in advance to all for any help on the matter |
|
|
|
|
|
|
|
|
Is this a Windows BMP? Depends if by monochrome you mean 1-bit black-and-white or 8-bit greyscale.
Generally it consists of a header describing dimensions and at least two palette entries, then the bitmap itself, with each scanline aligned on a DWORD boundary (not the same as the classical definition of a double-word, fixed at four bytes). So if you had an 8-bit greyscale image with dimensions 17x17, you would get 17 rows of 20 bytes, the nearest multiple. When drawn the padding bytes are ignored. Need more info, really. |
|
|
|
|
|
|
|
|
Hi
thank you for your reply. ill explain stage by stage. basically [1] create file in graphics package ie paint shop pro 9 i used for the experiment. [2] convert to monochrom windows bitmap purely black and white so to creat the principle the 1 = black , 0 = white or inverted. [3] open file for output as binary [4] using pointer with 2 levels of indirection index pointer position in file read array data and store in variable [5] open serial port say com2 for example for append and strobe data in variable out com port as binary 9600,N,8,1 for communication with PIC device utilizing MAX202CPE RS232 to TTL to 16F690 Thats what the sequence of operations as it will be if i can understand how the format is stored from a bitmap file. i know the first part of the file has BOF then BM to represent bitmap then a string of data ie how big the file is colour etc etc but i dont know where the setup data ends and where the image data begins and how its formatted by way of 8bit or 16bit string length and what the end of line marker is. otherwise as u know if its 16bit and i read it as 8 bit with no end of line marker ie null character ill get all manor of wierd and wonderful things going on...... if you could help that would be great. Best Regards Iain |
|
|
|
|
|
|
|
|
If you search on MSDN for the BITMAPFILEHEADER structure, this includes the member "bfOffBits" which will indicate where (relative to the beginning of the structure) the actual bitmap data begins.
A 1 bpp bitmap will express eight pixels in a single byte. DWORD-aligned scanlines still apply here. The most significant bit is the leftmost pixel. Bear in mind that if you are planning on ignoring the rest of the header (the BITMAPINFOHEADER structure), bitmaps are usually stored on disk upside-down, *unless* the biHeight member is negative. So you may have to flip the data once read, or have the pointer read the last scanline, then move backwards to the next (previous) line. |
|
|
|
|
|
|
|
|
i see what you mean starting at the EOF each block of data represents 1 row but if read 1 block at a time as you say the MSB is LHS of map so have to read map header to get width and height to set number of pixels in row and number of col in file read backwards to BOF unless map size is fixed which may or may not be practical will have to look into the practicalities..........
Many thanks for the info it looks so obvious now cheers for explaining that Best regards Iain |
|
|
|
|
|
IET
» Information technology
»
decoding monochrome bitmap files
|
Topic Tools |
FuseTalk Standard Edition v3.2 - © 1999-2013 FuseTalk Inc. All rights reserved.