revised color conversion methods

This commit is contained in:
codeanticode
2013-08-19 15:46:15 -04:00
parent bc273ea3ae
commit b850b53427
3 changed files with 1710 additions and 1797 deletions
@@ -206,7 +206,6 @@ public class Video implements PConstants {
int t = 0;
int p = 0;
if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
// RGBA to ARGB conversion: shifting RGB 8 bits to the right,
// and placing A 24 bits to the left.
for (int y = 0; y < height; y++) {
@@ -215,18 +214,14 @@ public class Video implements PConstants {
pixels[t++] = (pixel >>> 8) | ((pixel << 24) & 0xFF000000);
}
}
} else {
// We have to convert ABGR into ARGB, so R and B must be swapped,
// A and G just brought back in.
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int pixel = pixels[p++];
pixels[t++] = ((pixel & 0xFF) << 16) |
((pixel & 0xFF0000) >> 16) |
pixels[t++] = ((pixel & 0xFF) << 16) | ((pixel & 0xFF0000) >> 16) |
(pixel & 0xFF00FF00);
}
}
}