Example usage for android.graphics Matrix postScale

List of usage examples for android.graphics Matrix postScale

Introduction

In this page you can find the example usage for android.graphics Matrix postScale.

Prototype

public boolean postScale(float sx, float sy) 

Source Link

Document

Postconcats the matrix with the specified scale.

Usage

From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java

private Bitmap fitInsideSquare(Bitmap b, int sideLength) {
    int grabWidth = b.getWidth();
    int grabHeight = b.getHeight();

    float scaleX = ((float) sideLength) / grabWidth;
    float scaleY = ((float) sideLength) / grabHeight;
    float scale = Math.min(scaleX, scaleY);

    Matrix m = new Matrix();
    m.postScale(scale, scale);

    return Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), m, true);
}

From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java

private Bitmap makeInsideSquare(Bitmap b, int sideLength) {
    int grabWidth = b.getWidth();
    int grabHeight = b.getHeight();
    if (grabWidth > grabHeight) {
        grabWidth = grabHeight;/*from www. ja va  2 s. c o m*/
    } else {
        grabHeight = grabWidth;
    }

    float scale = ((float) sideLength) / grabWidth;

    Matrix m = new Matrix();
    m.postScale(scale, scale);

    return Bitmap.createBitmap(b, 0, 0, grabWidth, grabHeight, m, true);
}

From source file:com.bofsoft.laio.laiovehiclegps.Fragment.BaiduMapFragment.java

private void addOverlay(GPSInfoData gpsInfoData) {//marker ?? ?
    LatLng llA = new LatLng(gpsInfoData.Latitude, gpsInfoData.Longitude);
    // GPSGPS??????
    CoordinateConverter converter = new CoordinateConverter();
    converter.from(CoordinateConverter.CoordType.GPS);
    // sourceLatLng???
    converter.coord(llA);/*from w ww. j a  v  a  2s . c  o m*/
    //        desLatLng = converter.convert();
    LatLng tmpLL = converter.convert();

    View v_temp = LayoutInflater.from(getActivity()).inflate(R.layout.map_marker, null);//
    TextView tv_temp = (TextView) v_temp.findViewById(R.id.tv_marker);//?textview
    ImageView img_temp = (ImageView) v_temp.findViewById(R.id.iv_marker);//?imageview
    tv_temp.setText(gpsInfoData.License);//?
    if (gpsInfoData.Status == 0) {
        img_temp.setImageResource(imgIds[0]);//marker
        bitmap = BitmapFactory.decodeResource(getResources(), imgIds[0]);
    } else {
        img_temp.setImageResource(imgIds[2]);//marker
        bitmap = BitmapFactory.decodeResource(getResources(), imgIds[2]);
    }
    Matrix matrix = new Matrix();
    img_temp.setScaleType(ImageView.ScaleType.MATRIX); //required
    matrix.postScale(1, 1);
    //ImageViewImage
    int dw = bitmap.getWidth();
    int dh = bitmap.getHeight();
    matrix.postRotate((float) gpsInfoData.Direction, (float) dw / 2, (float) dh / 2);//
    img_temp.setImageMatrix(matrix);
    bd_temp = BitmapDescriptorFactory.fromView(v_temp);//?marker
    MarkerOptions oo = new MarkerOptions().position(tmpLL).icon(bd_temp).anchor(0.5f, 1.0f).zIndex(15);
    Marker mMarkerA = (Marker) (mBaiduMap.addOverlay(oo));
    Bundle bundle = new Bundle();
    bundle.putString("License", gpsInfoData.getLicense());
    mMarkerA.setExtraInfo(bundle);
}

From source file:com.goka.flickableview.ImageViewTouchBase.java

protected void getProperBaseMatrix(Drawable drawable, Matrix matrix, RectF rect) {
    float w = mBitmapRect.width();
    float h = mBitmapRect.height();
    float widthScale, heightScale;

    matrix.reset();/* ww  w . j a va 2  s .  c  o  m*/

    widthScale = rect.width() / w;
    heightScale = rect.height() / h;
    float scale = Math.min(widthScale, heightScale);
    matrix.postScale(scale, scale);
    matrix.postTranslate(rect.left, rect.top);

    float tw = (rect.width() - w * scale) / 2.0f;
    float th = (rect.height() - h * scale) / 2.0f;
    matrix.postTranslate(tw, th);
    printMatrix(matrix);
}

From source file:com.annanovas.bestprice.DashBoardEditActivity.java

private Bitmap imageProcess(Bitmap imageBitmap) {
    int width = imageBitmap.getWidth();
    int height = imageBitmap.getHeight();
    int newWidth = 1000;
    int newHeight = 1000;
    if (width > 1000) {
        double x = (double) width / 1000d;
        newHeight = (int) (height / x);
        newWidth = 1000;/*from w w w  .j  a  va 2s  .c o  m*/
    } else if (height > 1000) {
        double x = (double) height / 1000d;
        newWidth = (int) (width / x);
        newHeight = 1000;
    }
    // calculate the scale - in this case = 0.4f
    ExifInterface exif = null;
    int rotationAngle = 0;
    try {
        exif = new ExifInterface(imageUri);
        String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
        // showLog("orientString:" + orientString + " DateTime:" + exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH));
        int orientation = orientString != null ? Integer.parseInt(orientString)
                : ExifInterface.ORIENTATION_NORMAL;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_90)
            rotationAngle = 90;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_180)
            rotationAngle = 180;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_270)
            rotationAngle = 270;
        //  showLog("Rotation Angle:" + rotationAngle);
    } catch (IOException e) {
        // showLog("ExifInterface Failed!");
        e.printStackTrace();
    }
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    matrix.postRotate(rotationAngle);
    return Bitmap.createBitmap(imageBitmap, 0, 0, width, height, matrix, true);
}

From source file:com.cpic.taylor.logistics.activity.HomeActivity.java

public Bitmap big(Bitmap b, float x, float y) {
    int w = b.getWidth();
    int h = b.getHeight();
    float sx = (float) x / w;// ????
    float sy = (float) y / h;
    Matrix matrix = new Matrix();
    matrix.postScale(sx, sy); // ?
    Bitmap resizeBmp = Bitmap.createBitmap(b, 0, 0, w, h, matrix, true);
    return resizeBmp;
}

From source file:com.mylikes.likes.etchasketch.Slate.java

public void resetZoom() {
    mPanX = mPanY = 0;/*w  w  w.  java2s  . c  o  m*/
    final Matrix m = new Matrix();
    m.postScale(1f / DENSITY, 1f / DENSITY);
    setZoom(m);
    invalidate();
}

From source file:fr.bde_eseo.eseomega.GantierActivity.java

public Bitmap getResizedBitmap(Bitmap bm, int newSize) {
    int width = bm.getWidth();
    int height = bm.getHeight();

    float scale = ((float) newSize) / width;

    // CREATE A MATRIX FOR THE MANIPULATION
    Matrix matrix = new Matrix();
    // RESIZE THE BIT MAP
    matrix.postScale(scale, scale);

    // "RECREATE" THE NEW BITMAP
    return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
}

From source file:fr.bde_eseo.eseomega.GantierActivity.java

public Bitmap getScaledResizedBitmap(Bitmap bm, int newSize) {
    int width = bm.getWidth();
    int height = bm.getHeight();

    float scale;/*from   w  w w  . ja  v a  2 s  .  c  o  m*/

    if (height > width) { // portrait bitmap
        scale = ((float) newSize) / height;
    } else { // landscape bitmap
        scale = ((float) newSize) / width;
    }

    // CREATE A MATRIX FOR THE MANIPULATION
    Matrix matrix = new Matrix();
    // RESIZE THE BIT MAP
    matrix.postScale(scale, scale);

    // "RECREATE" THE NEW BITMAP
    return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
}

From source file:com.kjsaw.alcosys.ibacapp.IBAC.java

private Bitmap processBitmap(Bitmap orginalBitmap, int degrees) {
    Matrix matrixRotate = new Matrix();
    matrixRotate.setRotate(degrees, (float) orginalBitmap.getWidth() / 2,
            (float) orginalBitmap.getHeight() / 2);
    Bitmap rotatedBitmap = Bitmap.createBitmap(orginalBitmap, 0, 0, orginalBitmap.getWidth(),
            orginalBitmap.getHeight(), matrixRotate, true);

    int width = rotatedBitmap.getWidth();
    int height = rotatedBitmap.getHeight();

    int newWidth = 240;
    int newHeight = 320;

    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;

    Matrix matrixResize = new Matrix();
    if (Session.isFacingCamera) {
        matrixResize.setScale(-1, 1);// reversal
    }/*  w  ww  .j a  v a  2 s . com*/
    matrixResize.postScale(scaleWidth, scaleHeight);

    return Bitmap.createBitmap(rotatedBitmap, 0, 0, width, height, matrixResize, true);
}