-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.

jeanluc rotolo
  • 165
  • 1
  • 11
  • 1
    see if this works https://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. – Pemba Tamang Nov 16 '19 at 09:12

1 Answers1

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);
}
Stephan
  • 15,704
  • 7
  • 48
  • 63