|
|
|
@ -20,17 +20,19 @@ public class ByteOffsetImageCodec extends ImageCodec { |
|
|
|
|
@Override |
|
|
|
|
public void readComponents(ByteBuffer buf, int x, int y, int width, int[] components, byte[] tmp) { |
|
|
|
|
int i = (y * width + x) * bpp; |
|
|
|
|
buf.position(i); |
|
|
|
|
buf.get(tmp, 0, bpp); |
|
|
|
|
if (alphaPos != -1) { |
|
|
|
|
components[0] = buf.get(i + alphaPos) & 0xff; |
|
|
|
|
components[0] = tmp[alphaPos] & 0xff; |
|
|
|
|
} |
|
|
|
|
if (redPos != -1) { |
|
|
|
|
components[1] = buf.get(i + redPos) & 0xff; |
|
|
|
|
components[1] = tmp[redPos] & 0xff; |
|
|
|
|
} |
|
|
|
|
if (greenPos != -1) { |
|
|
|
|
components[2] = buf.get(i + greenPos) & 0xff; |
|
|
|
|
components[2] = tmp[greenPos] & 0xff; |
|
|
|
|
} |
|
|
|
|
if (bluePos != -1) { |
|
|
|
|
components[3] = buf.get(i + bluePos) & 0xff; |
|
|
|
|
components[3] = tmp[bluePos] & 0xff; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -38,17 +40,19 @@ public class ByteOffsetImageCodec extends ImageCodec { |
|
|
|
|
public void writeComponents(ByteBuffer buf, int x, int y, int width, int[] components, byte[] tmp) { |
|
|
|
|
int i = (y * width + x) * bpp; |
|
|
|
|
if (alphaPos != -1) { |
|
|
|
|
buf.put(i + alphaPos, (byte) components[0]); |
|
|
|
|
tmp[alphaPos] = (byte) components[0]; |
|
|
|
|
} |
|
|
|
|
if (redPos != -1) { |
|
|
|
|
buf.put(i + redPos, (byte) components[1]); |
|
|
|
|
tmp[redPos] = (byte) components[1]; |
|
|
|
|
} |
|
|
|
|
if (greenPos != -1) { |
|
|
|
|
buf.put(i + greenPos, (byte) components[2]); |
|
|
|
|
tmp[greenPos] = (byte) components[2]; |
|
|
|
|
} |
|
|
|
|
if (bluePos != -1) { |
|
|
|
|
buf.put(i + bluePos, (byte) components[3]); |
|
|
|
|
tmp[bluePos] = (byte) components[3]; |
|
|
|
|
} |
|
|
|
|
buf.position(i); |
|
|
|
|
buf.put(tmp, 0, bpp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|