Package com.tianscar.quickbitmap
Class BitmapChanger
- java.lang.Object
-
- com.tianscar.quickbitmap.BitmapChanger
-
public final class BitmapChanger extends java.lang.Object
A factory class providing functions to change bitmap.
-
-
Constructor Summary
Constructors Constructor Description BitmapChanger()
Instantiate a BitmapChanger for use.BitmapChanger(android.graphics.Bitmap src)
Create a copy bitmap for change and do not modify the source.BitmapChanger(android.graphics.Bitmap src, boolean recycle)
Create a copy bitmap for change.BitmapChanger(android.graphics.Bitmap src, int x, int y, int width, int height)
Copy a bitmap region from the source for change and do not modify the source.BitmapChanger(android.graphics.Bitmap src, android.graphics.Rect region)
Copy a bitmap region from the source for change and do not modify the source.BitmapChanger(android.graphics.Bitmap src, android.graphics.RectF region)
Copy a bitmap region from the source for change and do not modify the source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description android.graphics.Bitmap
change()
Return the changed bitmap.BitmapChanger
clipOval()
Clip oval on the whole bitmap.BitmapChanger
clipPath(android.graphics.Path path)
Clip path on the whole bitmap.BitmapChanger
clipRoundRect(float[] radii)
Clip round rect on the whole bitmap.BitmapChanger
clipRoundRect(float radiusX, float radiusY)
Clip round rect on the whole bitmap.BitmapChanger
crop(int left, int top, int right, int bottom)
Cut out region of the bitmap (can larger than the source).BitmapChanger
crop(int left, int top, int right, int bottom, boolean outBounds)
Cut out region of the bitmap.BitmapChanger
crop(android.graphics.Rect region)
Cut out region of the bitmap (can larger than the source).BitmapChanger
crop(android.graphics.RectF region)
Cut out region of the bitmap (can larger than the source).BitmapChanger
crop(android.graphics.RectF region, boolean outBounds)
Cut out region of the bitmap.BitmapChanger
crop(android.graphics.Rect region, boolean outBounds)
Cut out region of the bitmap.BitmapChanger
cut(int x, int y, int width, int height)
Cut out region of the bitmap (can larger than the source).BitmapChanger
cut(int x, int y, int width, int height, boolean outBounds)
Cut out region of the bitmap.BitmapChanger
fill(int x, int y, int color)
Seed filling.
Unsupported bitmap config:
Bitmap.Config.HARDWARE
Bitmap.Config.RGBA_F16BitmapChanger
flipHorizontally()
Flip the bitmap horizontally.BitmapChanger
flipVertically()
Flip the bitmap vertically.BitmapChanger
matrixChange(android.graphics.Matrix matrix)
Use matrix to change the bitmap (do not use filter).BitmapChanger
matrixChange(android.graphics.Matrix matrix, boolean filter)
Use matrix to change the bitmap.BitmapChanger
resize(int width, int height)
Scale the bitmap (do not use filter).BitmapChanger
resize(int width, int height, boolean filter)
Scale the bitmap.BitmapChanger
resizeHeight(int height)
Scale the bitmap (do not use filter).BitmapChanger
resizeHeight(int height, boolean filter)
Scale the bitmap.BitmapChanger
resizeWidth(int width)
Scale the bitmap (do not use filter).BitmapChanger
resizeWidth(int width, boolean filter)
Scale the bitmap.BitmapChanger
rotateDegrees(float degrees)
Rotate the bitmap (do not use filter).BitmapChanger
rotateDegrees(float degrees, boolean filter)
Rotate the bitmap.BitmapChanger
rotateRadians(float radians)
Rotate the bitmap (do not use filter).BitmapChanger
rotateRadians(float radians, boolean filter)
Rotate the bitmap.BitmapChanger
scale(float scale)
Scale the bitmap (do not use filter).BitmapChanger
scale(float scale, boolean filter)
Scale the bitmap.BitmapChanger
scale(float scaleX, float scaleY)
Scale the bitmap (do not use filter).BitmapChanger
scale(float scaleX, float scaleY, boolean filter)
Scale the bitmap.BitmapChanger
scaleX(float scaleX)
Scale the bitmap (do not use filter).BitmapChanger
scaleX(float scaleX, boolean filter)
Scale the bitmap.BitmapChanger
scaleY(float scaleY)
Scale the bitmap (do not use filter).BitmapChanger
scaleY(float scaleY, boolean filter)
Scale the bitmap.BitmapChanger
skew(float skewX, float skewY)
Skew the bitmap (do not use filter).BitmapChanger
skew(float skewX, float skewY, boolean filter)
Skew the bitmap.BitmapChanger
skew(float skewX, float skewY, float centerX, float centerY)
Skew the bitmap (do not use filter).BitmapChanger
skew(float skewX, float skewY, float centerX, float centerY, boolean filter)
Skew the bitmap.BitmapChanger
wrap(android.graphics.Bitmap src)
Create a copy bitmap for change and do not modify the source.BitmapChanger
wrap(android.graphics.Bitmap src, boolean recycle)
Create a copy bitmap for change.BitmapChanger
wrap(android.graphics.Bitmap src, int x, int y, int width, int height)
Copy a bitmap region from the source for change and do not modify the source.BitmapChanger
wrap(android.graphics.Bitmap src, android.graphics.Rect region)
Copy a bitmap region from the source for change and do not modify the source.BitmapChanger
wrap(android.graphics.Bitmap src, android.graphics.RectF region)
Copy a bitmap region from the source for change and do not modify the source.
-
-
-
Constructor Detail
-
BitmapChanger
public BitmapChanger(@NonNull android.graphics.Bitmap src)
Create a copy bitmap for change and do not modify the source.- Parameters:
src
- the source bitmap- See Also:
BitmapChanger(android.graphics.Bitmap,boolean)
-
BitmapChanger
public BitmapChanger(@NonNull android.graphics.Bitmap src, boolean recycle)
Create a copy bitmap for change. If @param recycle is false, it will not modify the source, else it will recycle the source bitmap.- Parameters:
src
- the source bitmaprecycle
- whether recycle source- See Also:
BitmapChanger()
-
BitmapChanger
public BitmapChanger(@NonNull android.graphics.Bitmap src, @NonNull android.graphics.Rect region)
Copy a bitmap region from the source for change and do not modify the source.- Parameters:
src
- the source bitmapregion
- the region- See Also:
BitmapChanger(android.graphics.Bitmap,int,int,int,int)
-
BitmapChanger
public BitmapChanger(@NonNull android.graphics.Bitmap src, @NonNull android.graphics.RectF region)
Copy a bitmap region from the source for change and do not modify the source.- Parameters:
src
- the source bitmapregion
- the region- See Also:
BitmapChanger(android.graphics.Bitmap,int,int,int,int)
-
BitmapChanger
public BitmapChanger(@NonNull android.graphics.Bitmap src, int x, int y, int width, int height)
Copy a bitmap region from the source for change and do not modify the source.- Parameters:
src
- the source bitmapx
- region lefty
- region topwidth
- region widthheight
- region height
-
BitmapChanger
public BitmapChanger()
Instantiate a BitmapChanger for use. You may wrap a bitmap for change.
-
-
Method Detail
-
wrap
public BitmapChanger wrap(@NonNull android.graphics.Bitmap src)
Create a copy bitmap for change and do not modify the source.- Parameters:
src
- the source bitmap- Returns:
- BitmapChanger the current instance
- See Also:
wrap(Bitmap, boolean)
-
wrap
public BitmapChanger wrap(@NonNull android.graphics.Bitmap src, boolean recycle)
Create a copy bitmap for change. If @param recycle is false, it will not modify the source, else it will recycle the source bitmap.- Parameters:
src
- the source bitmaprecycle
- whether recycle source- Returns:
- BitmapChanger the current instance
-
wrap
public BitmapChanger wrap(@NonNull android.graphics.Bitmap src, @NonNull android.graphics.Rect region)
Copy a bitmap region from the source for change and do not modify the source.- Parameters:
src
- the source bitmapregion
- the region- Returns:
- BitmapChanger the current instance
- See Also:
wrap(Bitmap, int, int, int, int)
-
wrap
public BitmapChanger wrap(@NonNull android.graphics.Bitmap src, @NonNull android.graphics.RectF region)
Copy a bitmap region from the source for change and do not modify the source.- Parameters:
src
- the source bitmapregion
- the region- Returns:
- BitmapChanger the current instance
- See Also:
wrap(Bitmap, int, int, int, int)
-
wrap
public BitmapChanger wrap(@NonNull android.graphics.Bitmap src, int x, int y, int width, int height)
Copy a bitmap region from the source for change and do not modify the source.- Parameters:
src
- the source bitmapx
- region lefty
- region topwidth
- region widthheight
- region height- Returns:
- BitmapChanger the current instance
-
cut
public BitmapChanger cut(int x, int y, int width, int height, boolean outBounds)
Cut out region of the bitmap.- Parameters:
x
- region lefty
- region topwidth
- region widthheight
- region heightoutBounds
- whether create bitmap which can larger than the source- Returns:
- BitmapChanger the current instance
-
cut
public BitmapChanger cut(int x, int y, int width, int height)
Cut out region of the bitmap (can larger than the source).- Parameters:
x
- region lefty
- region topwidth
- region widthheight
- region height- Returns:
- BitmapChanger the current instance
- See Also:
cut(int, int, int, int, boolean)
-
crop
public BitmapChanger crop(int left, int top, int right, int bottom, boolean outBounds)
Cut out region of the bitmap.- Parameters:
left
- region lefttop
- region topright
- region rightbottom
- region bottomoutBounds
- whether create bitmap which can larger than the source- Returns:
- BitmapChanger the current instance
-
crop
public BitmapChanger crop(int left, int top, int right, int bottom)
Cut out region of the bitmap (can larger than the source).- Parameters:
left
- region lefttop
- region topright
- region rightbottom
- region bottom- Returns:
- BitmapChanger the current instance
- See Also:
cut(int, int, int, int, boolean)
-
crop
public BitmapChanger crop(@NonNull android.graphics.Rect region, boolean outBounds)
Cut out region of the bitmap.- Parameters:
region
- the regionoutBounds
- whether create bitmap which can larger than the source- Returns:
- BitmapChanger the current instance
- See Also:
crop(int, int, int, int, boolean)
-
crop
public BitmapChanger crop(@NonNull android.graphics.Rect region)
Cut out region of the bitmap (can larger than the source).- Parameters:
region
- the region- Returns:
- BitmapChanger the current instance
- See Also:
crop(Rect, boolean)
-
crop
public BitmapChanger crop(@NonNull android.graphics.RectF region, boolean outBounds)
Cut out region of the bitmap.- Parameters:
region
- the regionoutBounds
- whether create bitmap which can larger than the source- Returns:
- BitmapChanger the current instance
- See Also:
crop(int, int, int, int, boolean)
-
crop
public BitmapChanger crop(@NonNull android.graphics.RectF region)
Cut out region of the bitmap (can larger than the source).- Parameters:
region
- the region- Returns:
- BitmapChanger the current instance
- See Also:
crop(RectF, boolean)
-
clipPath
public BitmapChanger clipPath(@NonNull android.graphics.Path path)
Clip path on the whole bitmap.- Parameters:
path
- path to clip- Returns:
- BitmapChanger the current instance
-
clipOval
public BitmapChanger clipOval()
Clip oval on the whole bitmap.- Returns:
- BitmapChanger the current instance
- See Also:
clipPath(Path)
-
clipRoundRect
public BitmapChanger clipRoundRect(float radiusX, float radiusY)
Clip round rect on the whole bitmap.- Parameters:
radiusX
- radius xradiusY
- radius y- Returns:
- BitmapChanger the current instance
- See Also:
clipPath(Path)
-
clipRoundRect
public BitmapChanger clipRoundRect(@NonNull float[] radii)
Clip round rect on the whole bitmap.- Parameters:
radii
- radii- Returns:
- BitmapChanger the current instance
- See Also:
clipPath(Path)
-
matrixChange
public BitmapChanger matrixChange(@NonNull android.graphics.Matrix matrix, boolean filter)
Use matrix to change the bitmap.- Parameters:
matrix
- the matrix for changefilter
- whether use filter- Returns:
- BitmapChanger the current instance
-
matrixChange
public BitmapChanger matrixChange(@NonNull android.graphics.Matrix matrix)
Use matrix to change the bitmap (do not use filter).- Parameters:
matrix
- the matrix for change- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix, boolean)
-
rotateDegrees
public BitmapChanger rotateDegrees(float degrees, boolean filter)
Rotate the bitmap.- Parameters:
degrees
- the degreesfilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix, boolean)
-
rotateDegrees
public BitmapChanger rotateDegrees(float degrees)
Rotate the bitmap (do not use filter).- Parameters:
degrees
- the degrees- Returns:
- BitmapChanger the current instance
- See Also:
rotateDegrees(float, boolean)
-
rotateRadians
public BitmapChanger rotateRadians(float radians, boolean filter)
Rotate the bitmap.- Parameters:
radians
- the radiansfilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
rotateDegrees(float, boolean)
-
rotateRadians
public BitmapChanger rotateRadians(float radians)
Rotate the bitmap (do not use filter).- Parameters:
radians
- the radians- Returns:
- BitmapChanger the current instance
- See Also:
rotateRadians(float, boolean);
-
flipHorizontally
public BitmapChanger flipHorizontally()
Flip the bitmap horizontally.- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix)
-
flipVertically
public BitmapChanger flipVertically()
Flip the bitmap vertically.- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix)
-
skew
public BitmapChanger skew(float skewX, float skewY, float centerX, float centerY, boolean filter)
Skew the bitmap.- Parameters:
skewX
- skew xskewY
- skew ycenterX
- center xcenterY
- center yfilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix, boolean)
-
skew
public BitmapChanger skew(float skewX, float skewY, float centerX, float centerY)
Skew the bitmap (do not use filter).- Parameters:
skewX
- skew xskewY
- skew ycenterX
- center xcenterY
- center y- Returns:
- BitmapChanger the current instance
- See Also:
skew(float, float, float, float, boolean)
-
skew
public BitmapChanger skew(float skewX, float skewY, boolean filter)
Skew the bitmap.- Parameters:
skewX
- skew xskewY
- skew yfilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix, boolean)
-
skew
public BitmapChanger skew(float skewX, float skewY)
Skew the bitmap (do not use filter).- Parameters:
skewX
- skew xskewY
- skew y- Returns:
- BitmapChanger the current instance
- See Also:
skew(float, float, boolean)
-
scale
public BitmapChanger scale(float scaleX, float scaleY, boolean filter)
Scale the bitmap.- Parameters:
scaleX
- x scalescaleY
- y scalefilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
matrixChange(Matrix, boolean)
-
scale
public BitmapChanger scale(float scaleX, float scaleY)
Scale the bitmap (do not use filter).- Parameters:
scaleX
- x scalescaleY
- y scale- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float, boolean)
-
scale
public BitmapChanger scale(float scale, boolean filter)
Scale the bitmap.- Parameters:
scale
- x & y scalefilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float, boolean)
-
scale
public BitmapChanger scale(float scale)
Scale the bitmap (do not use filter).- Parameters:
scale
- x & y scale- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float)
-
scaleX
public BitmapChanger scaleX(float scaleX, boolean filter)
Scale the bitmap.- Parameters:
scaleX
- x scalefilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float, boolean)
-
scaleX
public BitmapChanger scaleX(float scaleX)
Scale the bitmap (do not use filter).- Parameters:
scaleX
- x scale- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float)
-
scaleY
public BitmapChanger scaleY(float scaleY, boolean filter)
Scale the bitmap.- Parameters:
scaleY
- y scalefilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float, boolean)
-
scaleY
public BitmapChanger scaleY(float scaleY)
Scale the bitmap (do not use filter).- Parameters:
scaleY
- y scale- Returns:
- BitmapChanger the current instance
- See Also:
scale(float, float)
-
resize
public BitmapChanger resize(int width, int height, boolean filter)
Scale the bitmap.- Parameters:
width
- scaled widthheight
- scaled heightfilter
- whether use filter- Returns:
- BitmapChanger the current instance
-
resize
public BitmapChanger resize(int width, int height)
Scale the bitmap (do not use filter).- Parameters:
width
- scaled widthheight
- scaled height- Returns:
- BitmapChanger the current instance
- See Also:
resize(int, int, boolean)
-
resizeWidth
public BitmapChanger resizeWidth(int width, boolean filter)
Scale the bitmap.- Parameters:
width
- scaled widthfilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
resize(int, int, boolean)
-
resizeWidth
public BitmapChanger resizeWidth(int width)
Scale the bitmap (do not use filter).- Parameters:
width
- scaled width- Returns:
- BitmapChanger the current instance
- See Also:
resize(int, int)
-
resizeHeight
public BitmapChanger resizeHeight(int height, boolean filter)
Scale the bitmap.- Parameters:
height
- scaled heightfilter
- whether use filter- Returns:
- BitmapChanger the current instance
- See Also:
resize(int, int, boolean)
-
resizeHeight
public BitmapChanger resizeHeight(int height)
Scale the bitmap (do not use filter).- Parameters:
height
- scaled height- Returns:
- BitmapChanger the current instance
- See Also:
resize(int, int)
-
change
@NonNull public android.graphics.Bitmap change()
Return the changed bitmap.- Returns:
- bitmap changed bitmap
-
fill
public BitmapChanger fill(int x, int y, int color)
Seed filling.
Unsupported bitmap config:
Bitmap.Config.HARDWARE
Bitmap.Config.RGBA_F16- Parameters:
x
- position xy
- position ycolor
- color to fill- Returns:
- BitmapChanger the current instance
-
-