* Better toString() methods for Image and Texture
* OGGLoader no longer fails if file length less than number of expected samples git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7237 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
3378222dfa
commit
efb9792c95
@ -534,6 +534,28 @@ public class Image extends GLObject implements Savable /*, Cloneable*/ {
|
|||||||
return mipMapSizes;
|
return mipMapSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append("[size=").append(width).append("x").append(height);
|
||||||
|
|
||||||
|
if (depth > 1)
|
||||||
|
sb.append("x").append(depth);
|
||||||
|
|
||||||
|
sb.append(", format=").append(format.name());
|
||||||
|
|
||||||
|
if (hasMipmaps())
|
||||||
|
sb.append(", mips");
|
||||||
|
|
||||||
|
if (getId() >= 0)
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
|
||||||
|
sb.append("]");
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == this) {
|
if (other == this) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -504,18 +504,15 @@ public abstract class Texture implements Asset, Savable, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
String imgTxt = null;
|
StringBuilder sb = new StringBuilder();
|
||||||
if (image != null){
|
sb.append(getClass().getSimpleName());
|
||||||
imgTxt = ", img="+image.getWidth()
|
sb.append("[name=").append(name);
|
||||||
+"x"+image.getHeight();
|
if (image != null)
|
||||||
if (image.getDepth() > 1)
|
sb.append(", image=").append(image.toString());
|
||||||
imgTxt += "x"+image.getDepth();
|
|
||||||
imgTxt += "-"+image.getFormat().name();
|
|
||||||
if (image.hasMipmaps())
|
|
||||||
imgTxt += "/mips";
|
|
||||||
}
|
|
||||||
|
|
||||||
return getClass().getSimpleName() + "[name="+name+imgTxt+"]";
|
sb.append("]");
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public boolean equals(Object other) {
|
// public boolean equals(Object other) {
|
||||||
|
@ -40,7 +40,6 @@ import com.jme3.audio.AudioKey;
|
|||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import de.jarnbjo.ogg.EndOfOggStreamException;
|
import de.jarnbjo.ogg.EndOfOggStreamException;
|
||||||
import de.jarnbjo.ogg.LogicalOggStream;
|
import de.jarnbjo.ogg.LogicalOggStream;
|
||||||
import de.jarnbjo.ogg.OggPage;
|
|
||||||
import de.jarnbjo.vorbis.IdentificationHeader;
|
import de.jarnbjo.vorbis.IdentificationHeader;
|
||||||
import de.jarnbjo.vorbis.VorbisStream;
|
import de.jarnbjo.vorbis.VorbisStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -136,8 +135,12 @@ public class OGGLoader implements AssetLoader {
|
|||||||
// System.out.println("Bytes Calculated: " + totalBytes);
|
// System.out.println("Bytes Calculated: " + totalBytes);
|
||||||
// System.out.println("Bytes Available: " + dataBytes.length);
|
// System.out.println("Bytes Available: " + dataBytes.length);
|
||||||
|
|
||||||
ByteBuffer data = BufferUtils.createByteBuffer(totalBytes);
|
// Take the minimum of the number of bytes available
|
||||||
data.put(dataBytes, 0, totalBytes).flip();
|
// and the expected duration of the audio.
|
||||||
|
int bytesToCopy = Math.min(totalBytes, dataBytes.length);
|
||||||
|
|
||||||
|
ByteBuffer data = BufferUtils.createByteBuffer(bytesToCopy);
|
||||||
|
data.put(dataBytes, 0, bytesToCopy).flip();
|
||||||
|
|
||||||
vorbisStream.close();
|
vorbisStream.close();
|
||||||
loStream.close();
|
loStream.close();
|
||||||
|
@ -43,6 +43,8 @@ public class RenderImageJme implements RenderImage {
|
|||||||
|
|
||||||
private Texture2D texture;
|
private Texture2D texture;
|
||||||
private Image image;
|
private Image image;
|
||||||
|
private int width;
|
||||||
|
private int height;
|
||||||
|
|
||||||
public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display){
|
public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display){
|
||||||
TextureKey key = new TextureKey(filename, true);
|
TextureKey key = new TextureKey(filename, true);
|
||||||
@ -55,6 +57,9 @@ public class RenderImageJme implements RenderImage {
|
|||||||
texture.setMagFilter(MagFilter.Bilinear);
|
texture.setMagFilter(MagFilter.Bilinear);
|
||||||
texture.setMinFilter(MinFilter.BilinearNoMipMaps);
|
texture.setMinFilter(MinFilter.BilinearNoMipMaps);
|
||||||
image = texture.getImage();
|
image = texture.getImage();
|
||||||
|
|
||||||
|
width = image.getWidth();
|
||||||
|
height = image.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderImageJme(Texture2D texture){
|
public RenderImageJme(Texture2D texture){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user