/** Creates a new Pixmap instance from the given file. The file must be a Png, Jpeg or Bitmap. Paletted formats are not * supported. * * @param file the {@link FileHandle} */ public Pixmap (FileHandle file) { try { byte[] bytes = file.readBytes(); pixmap = new Gdx2DPixmap(bytes, 0, bytes.length, 0); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load file: " + file, e); } }
/** Creates a new Pixmap instance from the given file. The file must be a Png, Jpeg or Bitmap. Paletted formats are not * supported. * * @param file the {@link FileHandle} */ public Pixmap (FileHandle file) { try { byte[] bytes = file.readBytes(); pixmap = new Gdx2DPixmap(bytes, 0, bytes.length, 0); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load file: " + file, e); } }
public boolean loadFile(final com.badlogic.gdx.files.FileHandle fileHandle) { final int len = (int)fileHandle.length(); if (len <= 0) throw new com.badlogic.gdx.utils.GdxRuntimeException("Incorrect file specified"); java.nio.ByteBuffer buff = com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(len); buff.put(fileHandle.readBytes()); buff.position(0); boolean result = loadFileFromMemory(buff, len); com.badlogic.gdx.utils.BufferUtils.disposeUnsafeByteBuffer(buff); return result; }
public boolean loadFile(final com.badlogic.gdx.files.FileHandle fileHandle) { final int len = (int)fileHandle.length(); if (len <= 0) throw new com.badlogic.gdx.utils.GdxRuntimeException("Incorrect file specified"); java.nio.ByteBuffer buff = com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(len); buff.put(fileHandle.readBytes()); buff.position(0); boolean result = loadFileFromMemory(buff, len); com.badlogic.gdx.utils.BufferUtils.disposeUnsafeByteBuffer(buff); return result; }
compressedData = ByteBuffer.wrap(file.readBytes());
compressedData = ByteBuffer.wrap(file.readBytes());
byte[] testBytes = Gdx.files.local("test.txt").readBytes(); if (Arrays.equals("test".getBytes(), testBytes)) message += "Read into byte array success\n";
private void testClasspath () throws IOException { // no classpath support on ios if (Gdx.app.getType() == ApplicationType.iOS) return; FileHandle handle = Gdx.files.classpath("com/badlogic/gdx/utils/arial-15.png"); if (!handle.exists()) fail(); if (handle.isDirectory()) fail(); try { handle.delete(); fail(); } catch (Exception expected) { } try { handle.list(); fail(); } catch (Exception expected) { } try { handle.read().close(); fail(); } catch (Exception ignored) { } FileHandle dir = Gdx.files.classpath("com/badlogic/gdx/utils"); if (dir.isDirectory()) fail(); FileHandle child = dir.child("arial-15.fnt"); if (!child.name().equals("arial-15.fnt")) fail(); if (!child.nameWithoutExtension().equals("arial-15")) fail(); if (!child.extension().equals("fnt")) fail(); handle.read().close(); if (handle.readBytes().length != handle.length()) fail(); }
if (copy.exists()) fail(); handle.read().close(); if (handle.readBytes().length != handle.length()) fail();
FileHandle from = Gdx.files.external("image.jpg"); byte[] data = from.readBytes(); ... FileHandle to = Gdx.files.local("image.jpg"); to.writeBytes(data);
public Face newFace(FileHandle font, int faceIndex) { byte[] data = font.readBytes(); return newMemoryFace(data, data.length, faceIndex); }
/** Creates a new Pixmap instance from the given file. The file must be a Png, Jpeg or Bitmap. Paletted formats are not * supported. * * @param file the {@link FileHandle} */ public Pixmap (FileHandle file) { try { byte[] bytes = file.readBytes(); pixmap = new Gdx2DPixmap(bytes, 0, bytes.length, 0); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load file: " + file, e); } }
private Pixmap getPixmap(FileHandle file) { byte[] bs = file.readBytes(); defByte[0] = bs[0]; defByte[1] = bs[1]; String str_head = bytesToHexString(defByte); if (str_head.equals("8950") || str_head.equals("ffd8")) { return new Pixmap(bs, 0, bs.length); } int k = bs[0]; for (int i = 1; i < bs.length; i++) { bs[i] = (byte) (bs[i] ^ k); } return new Pixmap(bs, 1, bs.length); }
public boolean loadFile(final com.badlogic.gdx.files.FileHandle fileHandle) { final int len = (int)fileHandle.length(); if (len <= 0) throw new com.badlogic.gdx.utils.GdxRuntimeException("Incorrect file specified"); java.nio.ByteBuffer buff = com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(len); buff.put(fileHandle.readBytes()); buff.position(0); boolean result = loadFileFromMemory(buff, len); com.badlogic.gdx.utils.BufferUtils.disposeUnsafeByteBuffer(buff); return result; }
compressedData = ByteBuffer.wrap(file.readBytes());
op.write(fileHandle.readBytes());
+ (vpaint.getTTFName().endsWith( ".ttf") ? "" : ".ttf")) .readBytes()); BufferedInputStream fb = new BufferedInputStream(in); font = Font.createFont(Font.TRUETYPE_FONT, fb).deriveFont(
op.write(fileHandle.readBytes());