public ArrayList<ByteBuffer> readData(boolean flip) throws IOException {
        int totalSize = 0;

        for (int i = 0; i < sizes.length; i++) {
            totalSize += sizes[i];
        }

        ArrayList<ByteBuffer> allMaps = new ArrayList<>();
        if (depth > 1 && !texture3D) {
            for (int i = 0; i < depth; i++) {
                if (compressed) {
                    allMaps.add(readDXT2D(flip, totalSize));
                } else if (grayscaleOrAlpha) {
                    allMaps.add(readGrayscale2D(flip, totalSize));
                } else {
                    allMaps.add(readRGB2D(flip, totalSize));
                }
            }
        } else if (texture3D) {
            if (compressed) {
                allMaps.add(readDXT3D(flip, totalSize));
            } else if (grayscaleOrAlpha) {
                allMaps.add(readGrayscale3D(flip, totalSize));
            } else {
                allMaps.add(readRGB3D(flip, totalSize));
            }

        } else {
            if (compressed) {
                allMaps.add(readDXT2D(flip, totalSize));
            } else if (grayscaleOrAlpha) {
                allMaps.add(readGrayscale2D(flip, totalSize));
            } else {
                allMaps.add(readRGB2D(flip, totalSize));
            }
        }

        return allMaps;
    }
Reads the image data from the InputStream in the required format.
If the file contains a cubemap image, it is loaded as 6 ByteBuffers
(potentially containing mipmaps if they were specified), otherwise
a single ByteBuffer is returned for a 2D image.

@param flip Flip the image data or not.
       For cubemaps, each of the cubemap faces is flipped individually.
       If the image is DXT compressed, no flipping is done.
@return An ArrayList containing a single ByteBuffer for a 2D image, or 6 ByteBuffers for a cubemap.
        The cubemap ByteBuffer order is PositiveX, NegativeX, PositiveY, NegativeY, PositiveZ, NegativeZ.

@throws java.io.IOException If an error occurred while reading from the stream.
jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java