Lextree Simply the best software for managing legal entities and documents.
The Berkman Letter Practical analysis and commentary for business, law, and more.

how to resize image android studio

0
stars
0
answers
8
views
  <com.project.widget.PaintView
        android:id="@+id/paint_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_weight="1"


/>
I am trying to display an image in imageView in landscape mode. when I select image from list, this image becomes stretched. This my code in xml
my code java 

i got a stretched image.

how can resize image

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    if(bitmap == null){
    Bitmap srcBitmap = BitmapFactory.decodeResource(getResources(), Common.PICTURE_SELECTED);


 bitmap= Bitmap.createScaledBitmap(srcBitmap, w,h,false);
      
    for(int i=0;i<bitmap.getWidth();i++){
        for(int j=0; j<bitmap.getHeight();j++){
            int alpha = 255 - brightness(bitmap.getPixel(i,j));
            if(alpha< 200){
                bitmap.setPixel(i,j,Color.WHITE);
            }else {
                bitmap.setPixel(i, j, Color.BLACK);
            }
            }
        }
    }