List of usage examples for java.lang Math log
@HotSpotIntrinsicCandidate public static double log(double a)
From source file:Main.java
public static File downSample(Context context, Uri uri) throws Exception { Bitmap b = null;/*w ww . jav a 2 s . c o m*/ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; int scale = 1; if (o.outHeight > MAX_SIZE || o.outWidth > MAX_SIZE) { scale = (int) Math.pow(2, (int) Math .round(Math.log(MAX_SIZE / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5))); } //Decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; InputStream is = context.getContentResolver().openInputStream(uri); b = BitmapFactory.decodeStream(is, null, o2); is.close(); File outputDir = context.getCacheDir(); File outputFile = File.createTempFile("avatar", ".jpg", outputDir); FileOutputStream fos = new FileOutputStream(outputFile); b.compress(Bitmap.CompressFormat.JPEG, 80, fos); fos.close(); return outputFile; }
From source file:Main.java
/** * Returns the lat/lng as an "Offset Normalized Mercator" pixel coordinate, * this is a coordinate that runs from 0..1 in latitude and longitude with 0,0 being * top left. Normalizing means that this routine can be used at any zoom level and * then multiplied by a power of two to get actual pixel coordinates. *//* w w w.ja va 2 s . c om*/ public static Point2D toNormalisedPixelCoords(double lat, double lng) { // first convert to Mercator projection // first convert the lat lon to mercator coordintes. if (lng > 180) { lng -= 360; } lng /= 360; lng += 0.5; lat = 0.5 - ((Math.log(Math.tan((Math.PI / 4) + ((0.5 * Math.PI * lat) / 180))) / Math.PI) / 2.0); return new Point2D.Double(lng, lat); }
From source file:Main.java
public static Bitmap decodeFile(File f, int maxSize) { Bitmap b = null;//from w w w . j a v a 2 s . c om try { //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; FileInputStream fis = new FileInputStream(f); BitmapFactory.decodeStream(fis, null, o); fis.close(); int scale = 1; if (o.outHeight > maxSize || o.outWidth > maxSize) { scale = (int) Math.pow(2, (int) Math .round(Math.log(maxSize / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5))); } //Decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; fis = new FileInputStream(f); b = BitmapFactory.decodeStream(fis, null, o2); fis.close(); } catch (IOException e) { } return b; }
From source file:Main.java
static public final float log(float a) { return (float) Math.log(a); }
From source file:Main.java
public static Bitmap decodeFileFromDrawable(int id, int maxSize, Context context) { Bitmap b = null;//w w w .jav a 2 s . c o m try { // Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; InputStream inputStream = context.getResources().openRawResource(id); BitmapFactory.decodeStream(inputStream, null, o); inputStream.close(); int scale = 1; if (o.outHeight > maxSize || o.outWidth > maxSize) { scale = (int) Math.pow(2, (int) Math .round(Math.log(maxSize / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5))); } // Decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; inputStream = context.getResources().openRawResource(id); b = BitmapFactory.decodeStream(inputStream, null, o2); inputStream.close(); } catch (IOException e) { } return b; }
From source file:Main.java
public static int getInSampleSize(double scale) { double log = Math.log(scale) / Math.log(2); double logCeil = Math.ceil(log); return ((int) Math.pow(2, logCeil) + 1); }
From source file:gedi.util.math.stat.distributions.LfcDistribution.java
public static double ptol(double p) { return Math.log(p / (1 - p)) / Math.log(2); }
From source file:Main.java
public static double atanh(double x) { return Math.log((1.0 + x) / (1.0 - x)) / 2.0; }
From source file:Main.java
public static String ReadableByteCount(long bytes) { if (bytes < 1024) return bytes + " B"; int exp = (int) (Math.log(bytes) / Math.log(1024)); String pre = String.valueOf("KMGTPE".charAt(exp - 1)); return String.format("%.1f %sB", bytes / Math.pow(1024, exp), pre); }
From source file:Main.java
/** * /*from ww w . j a v a2s . co m*/ * @param file */ public static void decodeFile(File file) { Bitmap bitmap = null; try { // Decode image size BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; FileInputStream fileInputStream = new FileInputStream(file); BitmapFactory.decodeStream(fileInputStream, null, options); fileInputStream.close(); int scale = 1; if (options.outHeight > 500 || options.outWidth > 500) { scale = (int) Math.pow(2, (int) Math.round( Math.log(500 / (double) Math.max(options.outHeight, options.outWidth)) / Math.log(0.5))); } // Decode with inSampleSize BitmapFactory.Options options2 = new BitmapFactory.Options(); options2.inSampleSize = scale; fileInputStream = new FileInputStream(file); bitmap = BitmapFactory.decodeStream(fileInputStream, null, options2); fileInputStream.close(); FileOutputStream output = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, output); output.flush(); output.close(); } catch (Exception e) { Log.e(TAG, e.getMessage()); } }