bitmap

Resizing a bitmap to a fixed value but without changing the aspect ratio

本秂侑毒 提交于 2020-11-30 05:10:41
问题 I'm looking for a solution for the following problem: how to change the size of a Bitmap to a fixed size (for example 512x128). The aspect ratio of the bitmap content must be preserved. I think it should be something like this: create an empty 512x128 bitmap scale the original bitmap down to fit the 512x128 pixels with keeping the aspect ratio copy the scaled into the empty bitmap (centered) What is the simplest way to achieve this? The reason for all this is, that the GridView messes the

Resizing a bitmap to a fixed value but without changing the aspect ratio

一世执手 提交于 2020-11-30 05:03:10
问题 I'm looking for a solution for the following problem: how to change the size of a Bitmap to a fixed size (for example 512x128). The aspect ratio of the bitmap content must be preserved. I think it should be something like this: create an empty 512x128 bitmap scale the original bitmap down to fit the 512x128 pixels with keeping the aspect ratio copy the scaled into the empty bitmap (centered) What is the simplest way to achieve this? The reason for all this is, that the GridView messes the

Select an area on bitmap with 4 points using Matrix.setPolyToPoly

南笙酒味 提交于 2020-08-21 04:54:29
问题 I am playing with bitmap on Android and I am facing an issue when selecting an area on the bitmap using the 4 points. Not all the sets of 4 points work for me. In some cases, the result is just a blank bitmap instead of the cropped bitmap (like in the picture) and there is not any error in logcat(even memory error). Here is the basic code I used to do the transformation. import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics