Round up the cropped bitmap
If there is a sample size > 1, make sure we round up the cropped bitmap. Otherwise, there may be edge cases where the relative crops end up being larger than the bitmap. This happens in the very specific case where: - sampleSize = 2.0 (or multiple of 2) - the total cropHint.left is odd - the bitmap width is even - there is a crop that goes until the very right of the bitmap In that case, to calculate the crop relative to the totalCrop, we apply a -totalCrop.left offset then downsample. By doing this, the right coordinate of the crop will be rounded up; whereas in the calculation of the cropped bitmap size will we don't round up since we don't apply a shift of an odd number of pixels. Flag: com.android.window.flags.multi_crop Bug: 352818167 Test: manually verify the bug with example bitmap Test: atest WallpaperCropperTest Change-Id: Iee3f63555810fe76033778fa95cbfb01a5171d7b
Loading
Please register or sign in to comment