private void writeRGBE(byte[] rgbe){ if (writeRGBE){ dataStore.put(rgbe); }else{ convertRGBEtoFloat(rgbe, tempF); dataStore.putShort(FastMath.convertFloatToHalf(tempF[0])) .putShort(FastMath.convertFloatToHalf(tempF[1])). putShort(FastMath.convertFloatToHalf(tempF[2])); } }
String ln = readString(in); ln = ln.trim(); if (ln.startsWith("#") || ln.equals("")){ dataStore.position(scanLineBytes * y); decodeScanline(in, width);
private void decodeScanline(InputStream in, int width) throws IOException{ if (width < 8 || width > 0x7fff){ // too short/long for RLE compression decodeScanlineUncompressed(in, width); } // check format byte[] data = new byte[4]; in.read(data); if (data[0] != 0x02 || data[1] != 0x02 || (data[2] & 0x80) != 0){ // not RLE data decodeScanlineUncompressed(in, width-1); }else{ // check scanline width int readWidth = (data[2] & 0xFF) << 8 | (data[3] & 0xFF); if (readWidth != width) throw new IOException("Illegal scanline width in HDR file: "+width+" != "+readWidth); // RLE data decodeScanlineRLE(in, width); } }
private boolean decodeScanlineUncompressed(InputStream in, int width) throws IOException{ byte[] rgbe = new byte[4]; for (int i = 0; i < width; i+=3){ if (in.read(rgbe) < 1) return false; writeRGBE(rgbe); } return true; }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); Image img = load(in, flip); return img; } finally { if (in != null){ in.close(); } } }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); Image img = load(in, flip); return img; } finally { if (in != null){ in.close(); } } }
private void decodeScanline(InputStream in, int width) throws IOException{ if (width < 8 || width > 0x7fff){ // too short/long for RLE compression decodeScanlineUncompressed(in, width); } // check format byte[] data = new byte[4]; in.read(data); if (data[0] != 0x02 || data[1] != 0x02 || (data[2] & 0x80) != 0){ // not RLE data decodeScanlineUncompressed(in, width-1); }else{ // check scanline width int readWidth = (data[2] & 0xFF) << 8 | (data[3] & 0xFF); if (readWidth != width) throw new IOException("Illegal scanline width in HDR file: "+width+" != "+readWidth); // RLE data decodeScanlineRLE(in, width); } }
String ln = readString(in); ln = ln.trim(); if (ln.startsWith("#") || ln.equals("")){ dataStore.position(scanLineBytes * y); decodeScanline(in, width);
private boolean decodeScanlineUncompressed(InputStream in, int width) throws IOException{ byte[] rgbe = new byte[4]; for (int i = 0; i < width; i+=3){ if (in.read(rgbe) < 1) return false; writeRGBE(rgbe); } return true; }
private void writeRGBE(byte[] rgbe){ if (writeRGBE){ dataStore.put(rgbe); }else{ convertRGBEtoFloat(rgbe, tempF); dataStore.putShort(FastMath.convertFloatToHalf(tempF[0])) .putShort(FastMath.convertFloatToHalf(tempF[1])). putShort(FastMath.convertFloatToHalf(tempF[2])); } }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); Image img = load(in, flip); return img; } finally { if (in != null){ in.close(); } } }
private void decodeScanline(InputStream in, int width) throws IOException{ if (width < 8 || width > 0x7fff){ // too short/long for RLE compression decodeScanlineUncompressed(in, width); } // check format byte[] data = new byte[4]; in.read(data); if (data[0] != 0x02 || data[1] != 0x02 || (data[2] & 0x80) != 0){ // not RLE data decodeScanlineUncompressed(in, width-1); }else{ // check scanline width int readWidth = (data[2] & 0xFF) << 8 | (data[3] & 0xFF); if (readWidth != width) throw new IOException("Illegal scanline width in HDR file: "+width+" != "+readWidth); // RLE data decodeScanlineRLE(in, width); } }
String ln = readString(in); ln = ln.trim(); if (ln.startsWith("#") || ln.equals("")){ dataStore.position(scanLineBytes * y); decodeScanline(in, width);
private boolean decodeScanlineUncompressed(InputStream in, int width) throws IOException{ byte[] rgbe = new byte[4]; for (int i = 0; i < width; i+=3){ if (in.read(rgbe) < 1) return false; writeRGBE(rgbe); } return true; }
private void writeRGBE(byte[] rgbe){ if (writeRGBE){ dataStore.put(rgbe); }else{ convertRGBEtoFloat(rgbe, tempF); dataStore.putShort(FastMath.convertFloatToHalf(tempF[0])) .putShort(FastMath.convertFloatToHalf(tempF[1])). putShort(FastMath.convertFloatToHalf(tempF[2])); } }