Jump to content
Sign in to follow this  

Parsing a bitmap file...

Recommended Posts

Im trying to load and read a monochrome bitmap, get the pixel data, then draw the image in mspaint. Iv got it to work good so far except for that the pixels arnt being parsed correctly

When i draw the image, the pixels seem to be shifted a little bit, i think im not taking padding fully into account.

Func imageData(ByRef $handle,ByRef $headerData)
    Local $8bit[8]

    $offSet     = DLLStructGetData($headerData,"dataOffset") ;offset to pixel data
    $arraySize  = DllStructGetData($headerData,"arraySize") ;size of data
    $rowSize    = DllStructGetData($headerData,"rowSize_pad") ;size of rows with padding
    $row        = DLLStructGetData($headerData,"rowSize")     ;size of rows
    $width      = DLLStructGetData($headerData,"width")     ;image width
    $height     = DLLStructGetData($headerData,"height")    ;image height
    Local $pixelData[$height][$width+1]
    For $y=0 To $height-1
        For $x=0 To $rowSize-1
            For $i = 0 To 7
                If $x == 27 AND $i >= 3 Then
                $val=BitAND($byte,$8bit[$i]) ;Check for each pixel in byte
                $pixelData[$y][$counter]=($val<>$8bit[$i]) ;add pixel to array
    return $pixelData

I had to fiddle with some of the loops and $counter to get it to actually render

And its just upside down because im reading the pixel data upside down.

Does anyone have any idea what is wrong xD






There's no place like ~/

Share this post

Link to post
Share on other sites

Ok, i figured out why the lines were all going in the wrong directions, the left most pixel is stored in the most significant bit, so i was basicly reading each byte backwards. I still, however, cant figure out how to get rid of the black bar across the side of the screen.

There's no place like ~/

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...