Java Array Swap swapOrder32(byte[] buffer, int byteOffset, int sampleCount)

Here you can find the source of swapOrder32(byte[] buffer, int byteOffset, int sampleCount)

Description

swap Order

License

Open Source License

Declaration

public static void swapOrder32(byte[] buffer, int byteOffset,
            int sampleCount) 

Method Source Code

//package com.java2s;

public class Main {
    public static void swapOrder32(byte[] buffer, int byteOffset,
            int sampleCount) {
        int byteMax = sampleCount * 4 + byteOffset - 3;
        int i = byteOffset;
        while (i < byteMax) {
            byte h = buffer[i];
            buffer[i] = buffer[i + 3];/* www  . j a va 2s . c om*/
            buffer[i + 3] = h;
            i++;
            h = buffer[i];
            buffer[i] = buffer[++i];
            buffer[i++] = h;
            i++;
        }
    }

    public static void swapOrder32(byte[] inBuffer, int inByteOffset,
            byte[] outBuffer, int outByteOffset, int sampleCount) {
        while (sampleCount > 0) {
            outBuffer[outByteOffset++] = inBuffer[inByteOffset + 3];
            outBuffer[outByteOffset++] = inBuffer[inByteOffset + 2];
            outBuffer[outByteOffset++] = inBuffer[inByteOffset + 1];
            outBuffer[outByteOffset++] = inBuffer[inByteOffset++];
            inByteOffset++;
            inByteOffset++;
            inByteOffset++;
            sampleCount--;
        }
    }
}

Related

  1. swapInt(byte[] b, int i)
  2. swapInts(byte b[], int off, int len)
  3. swapNumbers(int i, int j, double[] array)
  4. swapObjects(Object[] array, int a, int b)
  5. swapOrder16(byte[] buffer, int byteOffset, int sampleCount)
  6. swapParallel(Object[] x, Object[] y, int a, int b, int yrel)
  7. swapPerTowElement(int[] arr)
  8. swapReferences(Object[] a, int index1, int index2)
  9. swapRgbColorComponents(byte[] pixelArray)