Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Bitmask & Graphics Question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Babu Kalakrishnan, post: 588247"] [b][b][b][b] Actually I would like to see even the first value (image[r]) also to be and'ed with 0xFF before the shift. (May be the code works because the setRGB operation discards the top 8 bits). Since image is an array of bytes, the values held by it are assumed to be in the range -128 to +127. So if you don't perform the "&" operation, Java will sign extend the byte while performing the promotion to integer, and the MSB 24 bits will end up being "1" in case bit 7 of the byte value was 1. When you and with 0xFF, the sequence of operation is : "promote both values to int and perform the & operation to produce an integer result". So even if the top 24 bits become 1 during the promotion, the and operation will null them to zero. BK[/b][/b][/b][/b] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Bitmask & Graphics Question
Top