Extending TexturePixel functionality.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9430 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 13 years ago
parent a00c8231c6
commit a2b2a85cce
  1. 49
      engine/src/blender/com/jme3/scene/plugins/blender/textures/TexturePixel.java
  2. 2
      engine/src/blender/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderDDS.java

@ -51,7 +51,7 @@ public class TexturePixel implements Cloneable {
* @param b
* the blue value
*/
public void fromARGB8(float a, float r, float g, float b) {
public void fromARGB(float a, float r, float g, float b) {
this.alpha = a;
this.red = r;
this.green = g;
@ -77,6 +77,25 @@ public class TexturePixel implements Cloneable {
this.blue = b >= 0 ? b / 255.0f : 1.0f - ~b / 255.0f;
}
/**
* Copies the values from the given values.
*
* @param a
* the alpha value
* @param r
* the red value
* @param g
* the green value
* @param b
* the blue value
*/
public void fromARGB16(short a, short r, short g, short b) {
this.alpha = a >= 0 ? a / 65535.0f : 1.0f - ~a / 65535.0f;
this.red = r >= 0 ? r / 65535.0f : 1.0f - ~r / 65535.0f;
this.green = g >= 0 ? g / 65535.0f : 1.0f - ~g / 65535.0f;
this.blue = b >= 0 ? b / 65535.0f : 1.0f - ~b / 65535.0f;
}
/**
* Copies the intensity from the given value.
*
@ -215,6 +234,34 @@ public class TexturePixel implements Cloneable {
return (byte) (this.blue * 255.0f);
}
/**
* @return the alpha value of the pixel
*/
public short getA16() {
return (byte) (this.alpha * 65535.0f);
}
/**
* @return the alpha red of the pixel
*/
public short getR16() {
return (byte) (this.red * 65535.0f);
}
/**
* @return the green value of the pixel
*/
public short getG16() {
return (byte) (this.green * 65535.0f);
}
/**
* @return the blue value of the pixel
*/
public short getB16() {
return (byte) (this.blue * 65535.0f);
}
/**
* Merges two pixels (adds the values of each color).
*

@ -99,7 +99,7 @@ public class TextureBlenderDDS extends TextureBlenderAWT {
colors[i].toRGBA(pixelColor);
pixelColor[3] = alphas[i];
this.blendPixel(resultPixel, compressedMaterialColor != null ? compressedMaterialColor[i] : materialColor, pixelColor, blenderContext);
colors[i].fromARGB8(1, resultPixel[0], resultPixel[1], resultPixel[2]);
colors[i].fromARGB(1, resultPixel[0], resultPixel[1], resultPixel[2]);
int argb8 = colors[i].toARGB8();
short rgb565 = RGB565.ARGB8_to_RGB565(argb8);
newData.putShort(rgb565);

Loading…
Cancel
Save