Returns the number of vertical subdivisions the argument image needs to be divided into to respect argument size - Java java.lang

Java examples for java.lang:Math Number

Description

Returns the number of vertical subdivisions the argument image needs to be divided into to respect argument size

Demo Code


import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Main{
    /**/* w  w w  .  j a  v a  2s .co m*/
     * Returns the number of vertical subdivisions the argument image needs to
     * be divided into to respect argument maxTexDim size
     * 
     * @param sourceImg
     * @param maxTexDim
     * @return the number of texture matrices
     */
    public static int getNumTextureMatrixPerColumn(Image sourceImg,
            int maxTexDim) {
        if (null != sourceImg) {
            //define number of needed subdivisions
            int numSubTexPerColumn = 0, imgH = sourceImg.getHeight();

            while (maxTexDim * numSubTexPerColumn < imgH)
                ++numSubTexPerColumn;

            return numSubTexPerColumn;
        }

        return -1;
    }
}

Related Tutorials