mv2112 Posted August 19, 2011 Share Posted August 19, 2011 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. expandcollapse popupFunc imageData(ByRef $handle,ByRef $headerData) Local $8bit[8] $8bit[0]=1 $8bit[1]=2 $8bit[2]=4 $8bit[3]=8 $8bit[4]=16 $8bit[5]=32 $8bit[6]=64 $8bit[7]=128 $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 ConsoleWrite($width) Local $pixelData[$height][$width+1] FileSetPos($handle,$offSet,0) $filePos=FileGetPos($handle) For $y=0 To $height-1 $counter=0 For $x=0 To $rowSize-1 $byte=FileRead($handle,1) ConsoleWrite($x&Chr(0xA)) For $i = 0 To 7 If $x == 27 AND $i >= 3 Then ContinueLoop EndIf $val=BitAND($byte,$8bit[$i]) ;Check for each pixel in byte $pixelData[$y][$counter]=($val<>$8bit[$i]) ;add pixel to array $counter+=1 Next Next Next return $pixelData EndFunc 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 Thanks, mv2112Outcome.bmpImage.bmpDraw.au3 There's no place like ~/ Link to comment Share on other sites More sharing options...
mv2112 Posted August 19, 2011 Author Share Posted August 19, 2011 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 ~/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now