Here you can find the source of flip(ByteBuffer bytes, int width, int height)
public final static void flip(ByteBuffer bytes, int width, int height)
//package com.java2s; /*//from www .j av a 2s . c o m * Procedurality v. 0.1 rev. 20070307 * Copyright 2007 Oddlabs ApS * * * This file is part of Procedurality. * Procedurality is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * * Procedurality is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * You should have received a copy of the GNU General Public License * along with Foobar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ import java.nio.ByteBuffer; public class Main { public final static void flip(ByteBuffer bytes, int width, int height) { byte[] line = new byte[width]; byte[] line2 = new byte[width]; for (int i = 0; i < height / 2; i++) { bytes.position(i * width); bytes.get(line); bytes.position((height - i - 1) * width); bytes.get(line2); bytes.position(i * width); bytes.put(line2); bytes.position((height - i - 1) * width); bytes.put(line); } } }