CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Aug 2004
    Posts
    6

    Question for Bitmap Decoding

    Hi, I am trying to get the pixel info from a bitmap file but encountered some difficulties. The ones that I am trying is a monochrome (biBitCount == 1) and their header info are as follows:

    Test File ----------- (1) ----------- (2) --------- (3) ---------- (4) --------- (5) -------- (6)

    info got from bitmap header:

    bmWidth ---------- 84 ---------- 168 -------- 252 --------- 335 -------- 419 ------- 586
    bmHeight -------- 606 -------- 1211 ------ 1817 -------- 2422 ------- 3028 ----- 4239
    bmWidthBytes --- 12 ----------- 24 ---------- 32 ----------- 44 ---------- 56 -------- 76

    ==========================================================

    # bytes to get --- 12 ----------- 22 ---------- 32 ----------- 42 ---------- 54 ------- 74

    I know that Each line in the array of data for the bitmap must be LONG aligned (divisible by 4 bytes).

    Since I was decoding row by row, if taking the number of bytes specified as "bmWidthBytes" in the header for the entire row, and encoded the bit of each byte for the pixels (1 => white, 0 => black), only test file (1) and (3) got the image right, others would get a skewed result and some info missing at the bottom of image. This makes me think more bytes have been taken than necessary, which belong to the next row of image.

    If taking the number of bytes as "# bytes to get", then everything was OK. I got these with trial and error!

    Does any one see what is wrong and how to figure out the right number of bytes to take for the entire row? Thanks for any help in advance.

    Raymond
    Last edited by rayq; September 7th, 2004 at 11:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured