public static ImageMetaData getImageMetaData(String file){ ByteBuffer imageBuffer; try { imageBuffer = ioResourceToByteBuffer(file, 128 * 128); } catch (IOException e) { throw new RuntimeException(e); } IntBuffer x = BufferUtils.createIntBuffer(1); IntBuffer y = BufferUtils.createIntBuffer(1); IntBuffer channels = BufferUtils.createIntBuffer(1); // Use info to read image metadata without decoding the entire image. if (!stbi_info_from_memory(imageBuffer, x, y, channels)) { throw new RuntimeException("Failed to read image information: " + stbi_failure_reason()); } return new ImageMetaData(x.get(0), y.get(0), channels.get(0)); }
if (!stbi_info_from_memory(imageBuffer, w, h, c)) { throw new RuntimeException("Failed to read image information: " + stbi_failure_reason());