Android Custom View Learning Note 03 Pre-knowledgeBitMapClass
BitMapThe bitmap class, which has a nested class called Bitmap.Config , has four enumerated values inside. The purpose of this class is to define the quality of bitmap storage, that is, the number of bits stored in a pixel, and whether transparent, translucent colors (Possible bitmap configurations) can be displayed. A bitmap configuration Describes how pixels is stored. This affects the quality (color depth) as well as the ability to display transparent/translucent colors).
A Transparency R Red G Green B Blue
Bitmap.config Alpha_8 Only stores transparency, other colors are not stored
Bitmap.config argb_4444 16 per pixel four bits
Bitmap.config argb_8888 32 per pixel eight bits
Bitmap.config rgb_565 5-bit G accounted for 6 bits B accounted for 5 bits no Transparency (A)
Reference Blog
Rectangle class
RectClass, a rectangle is formed by defining four (left, top, right, and bottom) edges. What is awkward is that the parameter represents the distance from the x-axis or the y-axis of each edge.
RectFClass, ditto, different Rect parameter types are shaped, with F is a single-precision floating-point number. In addition, Rect objects can be constructed as arguments RectF .
A very important class.BitmapShaderBitmap renderer
BitmapShaderThe bitmap renderer, which uses bitmaps as textures to paint, sets a pattern to set different rendering effects (Shader used to draw a bitmap as a texture. The bitmap can repeated or mirrored by setting the tiling mode).
- Construction method
BitmapShader(Bitmap bitmap, Shader.TileMode tileX, Shader.TileMode tileY) , the parameters are, as the texture of the bitmap, the horizontal direction of the rendering method, the vertical direction of rendering.
- There is a nested class
Shader.TileMode tile pattern, which defines three enumerated types of variables.
CLAMPIf the renderer is outside the original boundary range, the color of the original boundary is copied out of the range.
REPEATIf the display range is larger than the size of the picture, the picture is repeatedly rendered horizontally and vertically, tiled.
MIRRORlike the previous one, it's just a mirror tile.
The first parameter is used for general use.
- The method for setting the warp matrix
public void setLocalMatrix(Matrix localM) .
- Reference Blog Android Learning notes advanced 16 Bitmapshader
PaintClass
There is a method in the class that sets Shader the Renderer object public Shader setShader(Shader shader) to set the renderer.
MatrixMatrix class
MatrixThere is a 3*3 matrix inside, there are deformation information, there is no constructor function. Only specific methods can be used to set the relevant parameters. This matrix is divided into four parts, namely proportional rotation, translation, proportional transformation, perspective transformation. Operation principle is the transformation of the Matrix, refer to the Android matrix theory and application of the detailed
-Set the method for scaling, with the public void setScale(float sx,float sy) parameters being horizontal and vertical scaling.
Not finished
Android Custom View Learning Note 03