Click here to Skip to main content
14,541,375 members

C / C++ / MFC

 
AnswerRe: parsing bitmap files (2) Pin
Richard MacCutchan14-Mar-20 22:13
mveRichard MacCutchan14-Mar-20 22:13 
GeneralRe: parsing bitmap files (2) Pin
fearless_15-Mar-20 3:09
Memberfearless_15-Mar-20 3:09 
GeneralRe: parsing bitmap files (2) Pin
Richard MacCutchan15-Mar-20 3:34
mveRichard MacCutchan15-Mar-20 3:34 
GeneralRe: parsing bitmap files (2) Pin
fearless_15-Mar-20 4:05
Memberfearless_15-Mar-20 4:05 
GeneralRe: parsing bitmap files (2) Pin
Richard MacCutchan15-Mar-20 4:24
mveRichard MacCutchan15-Mar-20 4:24 
GeneralRe: parsing bitmap files (2) Pin
fearless_15-Mar-20 7:02
Memberfearless_15-Mar-20 7:02 
GeneralRe: parsing bitmap files (2) Pin
Richard MacCutchan15-Mar-20 7:04
mveRichard MacCutchan15-Mar-20 7:04 
AnswerRe: parsing bitmap files (2) Pin
leon de boer15-Mar-20 0:25
Memberleon de boer15-Mar-20 0:25 
You are confused there are two headers one after another you need to read them both before deciding whether to do step 3 and I have put a few hints what you need to do

1.) Read BITMAPFILEHEADER check for "BM", hold offset to bitmap data
2.) Read BITMAPINFOHEADER calc DWORD line stride width from bitmap width and bitdepth, see if you have a palette if so do step 3 else step 4
3.) Read the index palette if the BMP has one
4.) Jump to file offset from step 1 that is your bitmap data. Now you need to remember each line is DWORD (4 byte aligned) that means if you multiply the bytes per each line pixel * bitmap width it has to equal 4. So lets give you an example if you bitmap is 24Bit so each pixel is 3 bytes. So if your image was one pixel in width the first line is the first 3 bytes then there is a pad of one dummy byte and the second line starts at the 4th byte. So there can be 0 to 3 extra bytes per line because each new line must start on a DWORD boundary. So the amount of data you need to read for a line can be a couple bytes more than the just multiplying the bitmpap width * bytes per pixel.

The dummy bytes are usually zero but some smart people worked out long ago if you make all your images odd so you have the extra bytes you can put a hidden watermark, or play spy and put secret messsages in the dummy bytes Smile | :)
In vino veritas

AnswerRe: parsing bitmap files (2) Pin
fearless_15-Mar-20 1:59
Memberfearless_15-Mar-20 1:59 
Questionc libraries needed to deal with bitmaps Pin
fearless_11-Mar-20 6:59
Memberfearless_11-Mar-20 6:59 
AnswerRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan11-Mar-20 7:44
mveRichard MacCutchan11-Mar-20 7:44 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_11-Mar-20 9:49
Memberfearless_11-Mar-20 9:49 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_11-Mar-20 21:51
Memberfearless_11-Mar-20 21:51 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan11-Mar-20 22:35
mveRichard MacCutchan11-Mar-20 22:35 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_11-Mar-20 23:27
Memberfearless_11-Mar-20 23:27 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan11-Mar-20 23:36
mveRichard MacCutchan11-Mar-20 23:36 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_12-Mar-20 0:18
Memberfearless_12-Mar-20 0:18 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan12-Mar-20 2:31
mveRichard MacCutchan12-Mar-20 2:31 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_12-Mar-20 4:40
Memberfearless_12-Mar-20 4:40 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan12-Mar-20 5:10
mveRichard MacCutchan12-Mar-20 5:10 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_13-Mar-20 3:22
Memberfearless_13-Mar-20 3:22 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan13-Mar-20 4:22
mveRichard MacCutchan13-Mar-20 4:22 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_13-Mar-20 7:50
Memberfearless_13-Mar-20 7:50 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan13-Mar-20 8:07
mveRichard MacCutchan13-Mar-20 8:07 
GeneralRe: c libraries needed to deal with bitmaps Pin
fearless_13-Mar-20 21:07
Memberfearless_13-Mar-20 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.