* .. and here's the change that makes the previous change actually faster

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9741 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent dbc59934a7
commit 47563c2cf1
  1. 20
      engine/src/core/com/jme3/texture/image/ByteOffsetImageCodec.java
  2. 2
      engine/src/core/com/jme3/texture/image/DefaultImageRaster.java

@ -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);
}
}

@ -27,7 +27,7 @@ public class DefaultImageRaster extends ImageRaster {
this.codec = ImageCodec.lookup(image.getFormat());
this.width = image.getWidth();
this.height = image.getHeight();
if (codec instanceof ByteAlignedImageCodec) {
if (codec instanceof ByteAlignedImageCodec || codec instanceof ByteOffsetImageCodec) {
this.temp = new byte[codec.bpp];
} else {
this.temp = null;

Loading…
Cancel
Save