0

hi guys i am new in android i don't know how to crop an image view in rectangle shape and crop image is selected through touchlistner in android please tell me how to solve this question

 view_child=crop_image_border;
        float x_point=view_child.getX();
        float y_point=view_child.getY();
        int x=(int)x_point;
        int y=(int)y_point;
        Bitmap  bitmap_crop=Bitmap.createBitmap(globalvariable.bitmap,x,y,view_child.getWidth(),view_child.getHeight());
Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
DUKE
  • 137
  • 1
  • 1
  • 7
  • see my answer here http://stackoverflow.com/questions/24057931/how-to-zoom-crop-a-image-and-display-the-croped-image-on-imageview/24058159#24058159 its about cropping a desired portion of a image using external library – Illegal Argument Jul 28 '14 at 14:50
  • what's the problem with the code you have posted ? – ben75 Jul 28 '14 at 14:52

1 Answers1

0

You code is true Show below code for your more info

    Bitmap mainBitmap = null;
    int pointX = 10, pointY = 10;
    int cropWidth = (int) (mainBitmap.getWidth() * 0.5f);
    int cropHeight = (int) (mainBitmap.getHeight() * 0.5f);
    Bitmap b = Bitmap.createBitmap(mainBitmap, pointX, pointY, cropWidth,
            cropHeight, null, true);

    // Notes 
    // pointX+cropWidth < mainBitmap.getWidth();
    // pointY+cropHeight < mainBitmap.getHeight();
Divyang Metaliya
  • 1,908
  • 1
  • 12
  • 14