-1

Im pretty new at programming and i am struggling to implement the cameraX analyzer https://codelabs.developers.google.com/codelabs/camerax-getting-started/#7 .

Can someone help convert this line of code val pixels = data.map { it.toInt() and 0xFF } to Java.

Ps. the variable data is a byte array.

1
  • 1
    see if this works stackoverflow.com/a/6057546/8528047 if I'm not wrong the comments there say that a byte array is being converted to int array so you could have just googled how to do that. Commented Nov 16, 2019 at 9:12

1 Answer 1

3

Map does nothing else than just applying an operation toInt() and 0xFF to every element it of a sequence data.

int[] pixels = new int[data.length];
for(int i=0; i < data.length; i++){
    pixels[i] = (data[i] & 0xFF);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.