Reorders an OpenGL pixel array (RGBA) into ARGB. The array must be of size width height. @param pixels int[]
(int[] pixels)
| 1068 | * @param pixels int[] |
| 1069 | */ |
| 1070 | protected void convertToARGB(int[] pixels) { |
| 1071 | int t = 0; |
| 1072 | int p = 0; |
| 1073 | if (PGL.BIG_ENDIAN) { |
| 1074 | // RGBA to ARGB conversion: shifting RGB 8 bits to the right, |
| 1075 | // and placing A 24 bits to the left. |
| 1076 | for (int y = 0; y < height; y++) { |
| 1077 | for (int x = 0; x < width; x++) { |
| 1078 | int pixel = pixels[p++]; |
| 1079 | pixels[t++] = (pixel >>> 8) | ((pixel << 24) & 0xFF000000); |
| 1080 | } |
| 1081 | } |
| 1082 | } else { |
| 1083 | // We have to convert ABGR into ARGB, so R and B must be swapped, |
| 1084 | // A and G just brought back in. |
| 1085 | for (int y = 0; y < height; y++) { |
| 1086 | for (int x = 0; x < width; x++) { |
| 1087 | int pixel = pixels[p++]; |
| 1088 | pixels[t++] = ((pixel & 0xFF) << 16) | ((pixel & 0xFF0000) >> 16) | |
| 1089 | (pixel & 0xFF00FF00); |
| 1090 | } |
| 1091 | } |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | |
| 1096 | /////////////////////////////////////////////////////////// |
no outgoing calls
no test coverage detected