On Aug 23, 2006, at 9:17 AM, Charles Yeomans wrote:
or i = Bitwise.BitAnd(mb.Long(offset), &00ffffff)
The only problem with the above approach is if you need to get the
first byte of MemoryBlock: mb.Long(-1).
or maybe you could use ColorValue(offset, 24).
This grabs the correct number of bytes, but then there is the matter
of converting the color value into an Integer.
In addition, you would have to deal with the fact that the number is
in the two's complement format which is unusual now-days.
Even though there would be some function overhead, I think that I
would at least try to create a method specifically to extract this
data from the MemoryBlock, using Extends. NOTE: function below is
written without OutOfBounds or NilObject conditions, same as other
MemoryBlock functions:
Function TwosComplement24bit(Extends m As MemoryBlock, offset As
Integer) As Integer
Static mc As MemoryBlock = NewMemoryBlock(4)
Dim i As Integer
mc.StringValue(1, 3) = m.StringValue(offset, 3)
i = mc.Int32Value(0)
If BitwiseAnd(i, &h00800000) Then
// negative value
Return -BitwiseAnd(i, &h007FFFFF)
Else
// positive value
Return -BitwiseAnd(i, &h007FFFFF)
End If
End Function
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>