Use two indexes and System.arraycopy()
, copying 3 elements each time:
for (int i = 0, j = 0; i < argbBytes.length; i += 4, j += 3)
{
System.arraycopy(argbBytes, i, thumbRGB888, j, 3);
}
Should be significantly faster. Not only does it get rid of the modulo and comparison, System.arraycopy()
is implemented with native code, relying on memcpy
which is going to be faster than individual assignments.