D
D
Dmitry Kharitonov2015-01-25 21:28:01
Java
Dmitry Kharitonov, 2015-01-25 21:28:01

What would such a C function look like in Java?

Hello. There is the following function in C:

void MergeBytes(PIXEL *pixel, unsigned char *p, int bytes)
{
    pixel->r = p[2];
    pixel->g = p[1];
    pixel->b = p[0];
    pixel->a = p[3];
}

Sometimes it is called like this:
MergeBytes(&(pixels[n]), p, bytes2read);
And sometimes like this:
MergeBytes(&(pixels[n]), &(p[1]), bytes2read);
Where the variable "p" is declared as unsigned char p[5].
Tell me how to rewrite this in Java.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kharitonov, 2015-01-25
@geakstr

Understood. You need to write like this:
pixel->r = p[3];
pixel->g = p[2];
pixel->b = p[1];
pixel->a = p[4];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question