Android Bitmap Crop getTrimmedLeft(Bitmap img, int border)

Here you can find the source of getTrimmedLeft(Bitmap img, int border)

Description

returns blank area of the image to the left direction of the image

Parameter

Parameter Description
img a parameter
border a parameter

Return

blank area of the image to the left direction of the image

Declaration

public static int getTrimmedLeft(Bitmap img, int border) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Color;

public class Main {
    /**// w  w  w.  j  a  v  a  2  s  .  c  o m
     * returns blank area of the image to the left direction of the image
     * @param img
     * @return blank area of the image to the left direction of the image
     */
    public static int getTrimmedLeft(Bitmap img) {
        int width = img.getWidth();
        int height = img.getHeight();
        int data = width;

        for (int i = 0; i < height; ++i) {
            for (int j = 0; j < width; ++j) {
                if (img.getPixel(j, i) != Color.TRANSPARENT && j < data) {
                    data = j;
                    break;
                }
            }
        }

        return data;
    }

    /**
     * returns blank area of the image to the left direction of the image
     * @param img
     * @param border
     * @return blank area of the image to the left direction of the image
     */
    public static int getTrimmedLeft(Bitmap img, int border) {
        int width = img.getWidth();
        int height = img.getHeight();
        int data = width;

        for (int i = 0; i < height; ++i) {
            for (int j = 0; j < width; ++j) {
                if (img.getPixel(j, i) != Color.TRANSPARENT && j < data) {
                    data = j;
                    break;
                }
            }
        }

        return data + border;
    }
}

Related

  1. cropBitmapToSquare(Bitmap bitmap, int squareLength)
  2. cropBitmapToSquare(String bitmapPath, int squareLength)
  3. getTrimmedBottom(Bitmap img)
  4. getTrimmedBottom(Bitmap img, int border)
  5. getTrimmedLeft(Bitmap img)
  6. getTrimmedRight(Bitmap img)
  7. getTrimmedRight(Bitmap img, int border)
  8. getTrimmedTop(Bitmap img)
  9. getTrimmedTop(Bitmap img, int border)