Image crop and resize in Android

后端 未结 8 1009
无人及你
无人及你 2020-12-19 15:58

I followed the instructions below to crop an image.

http://coderzheaven.com/index.php/2011/03/crop-an-image-in-android/

The height and width of the final cro

8条回答
  •  不知归路
    2020-12-19 16:29

        //get screen resolution;
        WindowManager display = getWindowManager();
        Point size = new Point();
        display.getDefaultDisplay().getSize(size);      
        int width = size.x;
        int height = size.y;
        // scale the bitmap according to the screen resolution  .
        Bitmap bMap = BitmapFactory.decodeResource(getResources(), .drawable.ima1);
        bMap = Bitmap.createScaledBitmap(bMap, width, height, true);
        // then crop under value of the screen size and bitmap! 
        bMap = Bitmap.createBitmap(bMap, 0, 0, width/2, height);
        Drawable drawa = new BitmapDrawable(getResources(),bMap);
    

    i hope to be usefull

提交回复
热议问题