How does the result from ReadBrushPixel and ReadPixel work?
The docs say it will give the result in RGB format, but the output I get does not look like that.
Example black color returns simply 0. white 16777215, 16701184 - yellow, 14423100 - red,
3978097 - green etc.
How to get these into a format where I can read the value 0-255 for each of R, G and B?
ReadBrushPixel usage
Re: ReadBrushPixel usage
These numbers are the RGB values. For example, take a hexadecimal look at your white value:
DebugPrint(HexStr(16777215)) returns $FFFFFF.
Now you could extract the green value, for example, by dividing by 256, taking the integer part (that removes blue), dividing by 256 again, taking the remainder (that removes red) and multiplying by 256 again.
Another way would be to use the logical operators and the bitwise operators.
But Hollywood makes it easier for you and has the functions Red(), Green() and Blue().
DebugPrint(HexStr(16777215)) returns $FFFFFF.
Now you could extract the green value, for example, by dividing by 256, taking the integer part (that removes blue), dividing by 256 again, taking the remainder (that removes red) and multiplying by 256 again.
Another way would be to use the logical operators and the bitwise operators.
But Hollywood makes it easier for you and has the functions Red(), Green() and Blue().
Code: Select all
z=16777215
DebugPrint(HexStr(z))
DebugPrint(Frac(Int(z/256)/256)*256)
DebugPrint((z And $00FF00)>>8)
DebugPrint(Green(z))
Re: ReadBrushPixel usage
Thanks for explaining
Re: ReadBrushPixel usage
But I made a mistake: The fourth line must, of course, only use bitwise operators, no logical.
Code: Select all
DebugPrint((z & $00FF00)>>8)