Tell me what's the problem? In ImageView I add a picture using Pisacco and for effect I increase its width by 200px, everything is fine and the picture looks great.
When you click on the button you need to set it as a background image. I take this picture from ImageView, get its size, get display size, do calculations
// Π¨ΠΈΡΠΈΠ½Π° ΠΈ Π²ΡΡΠΎΡΠ° Π΄ΠΈΡΠΏΠ»Π΅Ρ @SuppressWarnings("deprecation") public List<Integer> getScreen() { List<Integer> size = new ArrayList<>(); WindowManager wm = (WindowManager) getApplicationContext() .getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); final Point point = new Point(); try { display.getSize(point); } catch (java.lang.NoSuchMethodError ignore) { // Older device point.x = display.getWidth(); point.y = display.getHeight(); } size.add(point.x); size.add(point.y); return size; } // ΠΠ±ΡΠ΅Π·Π°Ρ ΠΈ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Ρ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ public void setWallpaper(Bitmap bitmap, List<Integer> size) { Log.d(TAG, "width display: " + size.get(0)); // 1280 - ΡΠΈΡΠΈΠ½Π° Π΄ΠΈΡΠΏΠ»Π΅Ρ Log.d(TAG, "height display: " + size.get(1)); // 720 - Π²ΡΡΠΎΡΠ° Π΄ΠΈΡΠΏΠ»Π΅Ρ Log.d(TAG, "width bitmap: " + bitmap.getWidth()); // 1480 - ΡΠΈΡΠΈΠ½Π° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Log.d(TAG, "height bitmap: " + bitmap.getHeight()); // 720 - Π²ΡΡΠΎΡΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Bitmap dstBmp; if (bitmap.getWidth() >= bitmap.getHeight()){ dstBmp = Bitmap.createBitmap( bitmap, bitmap.getWidth()/2 - size.get(0)/2, // x = 100 0, // y = 0 size.get(0), // width = 1280 size.get(1) // height = 720 ); } else { dstBmp = Bitmap.createBitmap( bitmap, 0, size.get(1)/2 - bitmap.getWidth()/2, size.get(0), size.get(1) ); } WallpaperManager wm = WallpaperManager.getInstance(getApplicationContext()); try { wm.setBitmap(dstBmp); } catch (IOException e) { e.printStackTrace(); } } When you update the ImageView with the processed image again, everything is fine, the width has decreased by 200px and the quality has not been affected. (img.setImageBitmap (dstBmp);)
I turn off the application and see this picture
Tell the newcomer what I am doing wrong and what is the reason? It feels like the picture is stretched twice in width and height when it is set to the background.

