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.

enter image description here

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

enter image description here

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.

  • Wallpaper always increases. Check on any picture from your gallery and see - Flippy
  • How then to be? Is there some sort of regularity on how much the picture is increased in height and width to make it larger while respecting the proportions? - webphp

0