Java Pixel to Width pxToFileChar256(int px, int charWidth)

Here you can find the source of pxToFileChar256(int px, int charWidth)

Description

convert pixel to file 1/256 character width

License

Open Source License

Declaration

public static int pxToFileChar256(int px, int charWidth) 

Method Source Code

//package com.java2s;

public class Main {
    /** convert pixel to file 1/256 character width */
    public static int pxToFileChar256(int px, int charWidth) {
        final double w = (double) px;
        return (int) Math.floor(w * 256 / charWidth + 0.5);
    }//  w  w w .j  a va 2s. com
}