* 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;
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
|
@ -504,18 +504,15 @@ public abstract class Texture implements Asset, Savable, Cloneable {
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
String imgTxt = null;
|
||||
if (image != null){
|
||||
imgTxt = ", img="+image.getWidth()
|
||||
+"x"+image.getHeight();
|
||||
if (image.getDepth() > 1)
|
||||
imgTxt += "x"+image.getDepth();
|
||||
imgTxt += "-"+image.getFormat().name();
|
||||
if (image.hasMipmaps())
|
||||
imgTxt += "/mips";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append("[name=").append(name);
|
||||
if (image != null)
|
||||
sb.append(", image=").append(image.toString());
|
||||
|
||||
return getClass().getSimpleName() + "[name="+name+imgTxt+"]";
|
||||
sb.append("]");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// public boolean equals(Object other) {
|
||||
|
@ -40,7 +40,6 @@ import com.jme3.audio.AudioKey;
|
||||
import com.jme3.util.BufferUtils;
|
||||
import de.jarnbjo.ogg.EndOfOggStreamException;
|
||||
import de.jarnbjo.ogg.LogicalOggStream;
|
||||
import de.jarnbjo.ogg.OggPage;
|
||||
import de.jarnbjo.vorbis.IdentificationHeader;
|
||||
import de.jarnbjo.vorbis.VorbisStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -136,8 +135,12 @@ public class OGGLoader implements AssetLoader {
|
||||
// System.out.println("Bytes Calculated: " + totalBytes);
|
||||
// System.out.println("Bytes Available: " + dataBytes.length);
|
||||
|
||||
ByteBuffer data = BufferUtils.createByteBuffer(totalBytes);
|
||||
data.put(dataBytes, 0, totalBytes).flip();
|
||||
// Take the minimum of the number of bytes available
|
||||
// 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();
|
||||
loStream.close();
|
||||
|
@ -43,6 +43,8 @@ public class RenderImageJme implements RenderImage {
|
||||
|
||||
private Texture2D texture;
|
||||
private Image image;
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display){
|
||||
TextureKey key = new TextureKey(filename, true);
|
||||
@ -55,6 +57,9 @@ public class RenderImageJme implements RenderImage {
|
||||
texture.setMagFilter(MagFilter.Bilinear);
|
||||
texture.setMinFilter(MinFilter.BilinearNoMipMaps);
|
||||
image = texture.getImage();
|
||||
|
||||
width = image.getWidth();
|
||||
height = image.getHeight();
|
||||
}
|
||||
|
||||
public RenderImageJme(Texture2D texture){
|
||||
|
Loading…
x
Reference in New Issue
Block a user