Question

My app gets a sequence of images, compresses each image with jpeg algorithm, which are stored as a byte arrays(1 img = 1 byte[]). Then it collects all the byte arrays into one array(just like matrix), but java compiler(or eclipse) says that it doesn't work. Here is the code of how I set the byte array into another byte array.

CompressedImage frameArrayElement = new CompressedImage(video.frame[i]);
byte[] currentFrame = frameArrayElement.compress(video.frame[i]);
package.setFrame(currentFrame, i);

And this is the code of function setFrame().

void setFrame(byte[] f, int i) {
    frames[i] = f;
}

Eclipse tells me about type mismatch and suggests switching "byte[] f" tot "byte f".

How should I sort this out?

Was it helpful?

Solution

In order for this assignment to work, frames needs to be declared as byte[][] in the class that has the setFrame method:

private byte[][] frames;

From the error that you posted it appears that frames is declared as byte[], not as byte[][]. That's why the compiler suggests making f a byte.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top