BitmapShader
public
class
BitmapShader
extends Shader
| java.lang.Object | ||
| ↳ | android.graphics.Shader | |
| ↳ | android.graphics.BitmapShader | |
Shader used to draw a bitmap as a texture. The bitmap can be repeated or mirrored by setting the tiling mode.
Summary
Constants | |
|---|---|
int |
FILTER_MODE_DEFAULT
This FilterMode value will respect the value of the Paint#isFilterBitmap flag while the shader is attached to the Paint. |
int |
FILTER_MODE_LINEAR
This FilterMode value will cause the shader to interpolate the output of the shader from a 2x2 grid of pixels nearest to the sample point (i.e. |
int |
FILTER_MODE_NEAREST
This FilterMode value will cause the shader to sample from the nearest pixel to the requested sample point. |
Public constructors | |
|---|---|
BitmapShader(Bitmap bitmap, Shader.TileMode tileX, Shader.TileMode tileY)
Call this to create a new shader that will draw with a bitmap. |
|
Public methods | |
|---|---|
int
|
getFilterMode()
Returns the filter mode used when sampling from this shader |
void
|
setFilterMode(int mode)
Set the filter mode to be used when sampling from this shader |
Inherited methods | |
|---|---|
Constants
FILTER_MODE_DEFAULT
public static final int FILTER_MODE_DEFAULT
This FilterMode value will respect the value of the Paint#isFilterBitmap flag while the shader is attached to the Paint.
The exception to this rule is when a Shader is attached as input to a RuntimeShader. In that case this mode will default to FILTER_MODE_NEAREST.
See also:
Constant Value: 0 (0x00000000)
FILTER_MODE_LINEAR
public static final int FILTER_MODE_LINEAR
This FilterMode value will cause the shader to interpolate the output of the shader from a 2x2 grid of pixels nearest to the sample point (i.e. bilinear interpolation).
This value will override the effect of Paint#isFilterBitmap.
See also:
Constant Value: 2 (0x00000002)
FILTER_MODE_NEAREST
public static final int FILTER_MODE_NEAREST
This FilterMode value will cause the shader to sample from the nearest pixel to the requested sample point.
This value will override the effect of Paint#isFilterBitmap.
See also:
Constant Value: 1 (0x00000001)
Public constructors
BitmapShader
public BitmapShader (Bitmap bitmap, Shader.TileMode tileX, Shader.TileMode tileY)
Call this to create a new shader that will draw with a bitmap.
| Parameters | |
|---|---|
bitmap |
Bitmap: The bitmap to use inside the shader
This value cannot be null. |
tileX |
Shader.TileMode: The tiling mode for x to draw the bitmap in.
This value cannot be null. |
tileY |
Shader.TileMode: The tiling mode for y to draw the bitmap in.
This value cannot be null. |
Public methods
getFilterMode
public int getFilterMode ()
Returns the filter mode used when sampling from this shader
| Returns | |
|---|---|
int |
Value is FILTER_MODE_DEFAULT, FILTER_MODE_NEAREST, or FILTER_MODE_LINEAR |
setFilterMode
public void setFilterMode (int mode)
Set the filter mode to be used when sampling from this shader
| Parameters | |
|---|---|
mode |
int: Value is FILTER_MODE_DEFAULT, FILTER_MODE_NEAREST, or FILTER_MODE_LINEAR |