Several common operations of Android bitmap: zoom, crop, rotate and offset

Android bitmap related operations

Several common operations: scaling, clipping, rotation, offset

Many operations need matrix support; Matrix processes the bitmap through the matrix, calculates the position of each pixel, and displays the bitmap. There is a 3x3 matrix in the matrix for image processing:

According to the variable name, you can guess the specific purpose: zoom x offset x translation x offset y zoom y translation y perspective 0 perspective 1 perspective 2

Matrix operations include set, pre and post; Set can directly set the values in the matrix; Pre is similar to matrix left multiplication; Post is similar to right multiplication in a matrix

After the original bitmap is calculated, a bitmap will be regenerated

Code snippet:

Button operation definition:

Problems encountered

Log is as follows. When ratio = 1, the new bitmap and the old bitmap have the same address

11-27 05:27:16.086 16723-16723/? D/rust: originBitmap = android.graphics. Bitmap@1e8849e 11-27 05:27:16.086 16723-16723/? D/rust: newBitmap = android.graphics. Bitmap@1e8849e

See for more information https://rustfisher.com

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>