如何在android中裁剪imageview

时间:2014-07-28 14:44:59

标签: android

大家好我是android的新手我不知道如何裁剪矩形形状的图像视图和裁剪图像是通过android中的touchlistner选择的 请告诉我如何解决这个问题

 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());

1 个答案:

答案 0 :(得分:0)

你的代码是真的 显示以下代码以获取更多信息

    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();
相关问题