Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

enter image description herehere outdata is buffer of size[8*1024],can you tell me the exactly what will happened after execution of above lines??

share|improve this question

put on hold as off-topic by Josh Petrie Sep 27 at 15:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

    
A bit more background would be nice. – Djindjidj Sep 27 at 6:39
    
I would suggest start by studying operators in Java. – wondra Sep 27 at 6:55
    
Please copy-paste the code, don't just insert an image of code. – Alexandre Vaillancourt Sep 27 at 14:06
up vote 0 down vote accepted

Your code looks like it takes an array with rgba values in the format [R, G, B, A, R, G, B, A...] and compresses it to the [RGBA, RGBA, RGBA...] format using bitwise operations (<< and &).

The & 0xFF part is called bitmasking, it makes the last 8 bits of the number stay the same, but others are zeroed.

0000110011101110 & 0xFF -> 0000000011101110

The number + (number2 << 8) concatenates the numbers, so the first 8 bits will contain the first number, the second 8 bits will contain the second number

10101010 << 8 -> 1010101000000000
10101010 + (11101110 << 8) -> 1110111010101010
share|improve this answer
    
@wondra java can't do bitwise operations on anything other than integers, wich are 32 bits, so yes, it's compression – Bálint Sep 27 at 7:09
    
It is very bold statement that taking 8 bits, implicitly making it 32 and then back 8 is compression. – wondra Sep 27 at 7:21
    
@wondra I don't think you understood my answer. The current code takes 4 32 bit (they are originally 32 bits, they never were 8 bit) numbers (that's 128 bits), takes their last 8 bits and puts them into 1 32 bit number. – Bálint Sep 27 at 7:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.