Bugfix: fixed a bug that raised IndexOutOfBounds exception when blending was applied to image with mipmaps. (commited once more because the previous version still had errors).
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10863 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
3dbe5fcec6
commit
1c26d91bb2
engine/src/blender/com/jme3/scene/plugins/blender/textures/blending
@ -73,13 +73,15 @@ public class TextureBlenderAWT extends AbstractTextureBlender {
|
||||
if (depth == 0) {
|
||||
depth = 1;
|
||||
}
|
||||
int bytesPerPixel = image.getFormat().getBitsPerPixel() >> 3;
|
||||
ArrayList<ByteBuffer> dataArray = new ArrayList<ByteBuffer>(depth);
|
||||
|
||||
float[] resultPixel = new float[4];
|
||||
for (int dataLayerIndex = 0; dataLayerIndex < depth; ++dataLayerIndex) {
|
||||
ByteBuffer data = image.getData(dataLayerIndex);
|
||||
data.rewind();
|
||||
ByteBuffer newData = BufferUtils.createByteBuffer(data.limit());
|
||||
int imagePixelCount = data.limit() / bytesPerPixel;
|
||||
ByteBuffer newData = BufferUtils.createByteBuffer(imagePixelCount * 4);
|
||||
|
||||
int dataIndex = 0, x = 0, y = 0, index = 0;
|
||||
while (index < data.limit()) {
|
||||
@ -87,11 +89,16 @@ public class TextureBlenderAWT extends AbstractTextureBlender {
|
||||
if (basePixelIO != null) {
|
||||
basePixelIO.read(baseImage, dataLayerIndex, basePixel, x, y);
|
||||
basePixel.toRGBA(materialColor);
|
||||
++x;
|
||||
if (x >= width) {
|
||||
x = 0;
|
||||
++y;
|
||||
}
|
||||
}
|
||||
|
||||
// reading the current texture's pixel
|
||||
pixelReader.read(image, dataLayerIndex, pixel, index);
|
||||
index += image.getFormat().getBitsPerPixel() >> 3;
|
||||
index += bytesPerPixel;
|
||||
pixel.toRGBA(pixelColor);
|
||||
if (negateTexture) {
|
||||
pixel.negate();
|
||||
@ -102,12 +109,6 @@ public class TextureBlenderAWT extends AbstractTextureBlender {
|
||||
newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f));
|
||||
newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f));
|
||||
newData.put(dataIndex++, (byte) (pixelColor[3] * 255.0f));
|
||||
|
||||
++x;
|
||||
if (x >= width) {
|
||||
x = 0;
|
||||
++y;
|
||||
}
|
||||
}
|
||||
dataArray.add(newData);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class TextureBlenderLuminance extends AbstractTextureBlender {
|
||||
for (int dataLayerIndex = 0; dataLayerIndex < depth; ++dataLayerIndex) {
|
||||
ByteBuffer data = image.getData(dataLayerIndex);
|
||||
data.rewind();
|
||||
ByteBuffer newData = BufferUtils.createByteBuffer(data.limit());
|
||||
ByteBuffer newData = BufferUtils.createByteBuffer(data.limit() * 4);
|
||||
|
||||
int dataIndex = 0, x = 0, y = 0;
|
||||
while (data.hasRemaining()) {
|
||||
@ -58,6 +58,12 @@ public class TextureBlenderLuminance extends AbstractTextureBlender {
|
||||
if (basePixelIO != null) {
|
||||
basePixelIO.read(baseImage, dataLayerIndex, basePixel, x, y);
|
||||
basePixel.toRGBA(materialColor);
|
||||
|
||||
++x;
|
||||
if (x >= width) {
|
||||
x = 0;
|
||||
++y;
|
||||
}
|
||||
}
|
||||
|
||||
this.getTinAndAlpha(data, format, negateTexture, tinAndAlpha);
|
||||
@ -66,12 +72,6 @@ public class TextureBlenderLuminance extends AbstractTextureBlender {
|
||||
newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f));
|
||||
newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f));
|
||||
newData.put(dataIndex++, (byte) (tinAndAlpha[1] * 255.0f));
|
||||
|
||||
++x;
|
||||
if (x >= width) {
|
||||
x = 0;
|
||||
++y;
|
||||
}
|
||||
}
|
||||
dataArray.add(newData);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user