Skip to content

Commit

Permalink
Treat BufferedImage.TYPE_INT_RGB, etc, as big endian when copying t…
Browse files Browse the repository at this point in the history
…o `Frame` for consistency
  • Loading branch information
saudet committed May 12, 2015
1 parent fe59f63 commit 487954e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/bytedeco/javacv/Java2DFrameConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.awt.image.WritableRaster;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
Expand Down Expand Up @@ -517,7 +518,7 @@ public static void copy(BufferedImage image, Frame frame, double gamma, boolean
int[] a = ((DataBufferInt)in).getData();
int stride = frame.imageStride;
if (out instanceof ByteBuffer) {
out = ((ByteBuffer)out).asIntBuffer();
out = ((ByteBuffer)out).order(ByteOrder.BIG_ENDIAN).asIntBuffer();
stride /= 4;
}
flipCopyWithGamma(IntBuffer.wrap(a, start, a.length - start), step, (IntBuffer)out, stride, gamma, false, flipChannels ? channels : 0);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/bytedeco/javacv/FrameConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public class FrameConverterTest {
WritableRaster raster2 = image2.getRaster();
byte[] array2 = ((DataBufferByte)raster2.getDataBuffer()).getData();
for (int j = 0; j < array.length; j++) {
int n = ((array2[4 * j + 3] & 0xFF) << 24) | ((array2[4 * j + 2] & 0xFF) << 16)
| ((array2[4 * j + 1] & 0xFF) << 8) | (array2[4 * j] & 0xFF);
int n = ((array2[4 * j ] & 0xFF) << 24) | ((array2[4 * j + 1] & 0xFF) << 16)
| ((array2[4 * j + 2] & 0xFF) << 8) | (array2[4 * j + 3] & 0xFF);
assertEquals(array[j], n);
}
}
Expand Down

0 comments on commit 487954e

Please sign in to comment.