public class PDFCanvas extends Canvas
The PDFCanvas is associated with a PDFPage, which is part of a PDFDocument. The basic workflow is:
// Create a PDF document, a page in the document, and get that page's PDFCanvas
PDFDocument pdfDoc = new PDFDocument();
PDFPage page = new PDFPage(PageFormat.LETTER);
pdfDoc.add(page);
PDFCanvas pdfCanvas = page.getCanvas();
// do drawing commands as on any other Canvas
drawDesign(pdfCanvas);
// write the PDF content for the page to a file
BufferedOutputStream fileStream = new BufferedOutputStream(new FileOutputStream(file));
pdfDoc.write(outStream);
fileStream.flush();
fileStream.close();
Note: Certain methods are unimplemented due to lack of support in PDF; these will throw an UnsupportedOperationException if used. Some additional features currently have no or limited support, as indicated below.
Supported operations:
Not supported:
Modifier and Type | Class and Description |
---|---|
static class |
PDFCanvas.EdgeType |
Canvas.VertexMode
Modifier and Type | Field and Description |
---|---|
static int |
DIRECTION_LTR
Flag for drawTextRun indicating left-to-right run direction.
|
static int |
DIRECTION_RTL
Flag for drawTextRun indicating right-to-left run direction.
|
static int |
PDF_STROKE_CAP_BUTT
Constants for stroke cap operators
|
static int |
PDF_STROKE_CAP_PROJECTING_SQUARE |
static int |
PDF_STROKE_CAP_ROUND |
static int |
PDF_STROKE_JOIN_BEVEL |
static int |
PDF_STROKE_JOIN_MITER
Constants for stroke join operators
|
static int |
PDF_STROKE_JOIN_ROUND |
ALL_SAVE_FLAG, CLIP_SAVE_FLAG, CLIP_TO_LAYER_SAVE_FLAG, FULL_COLOR_LAYER_SAVE_FLAG, HAS_ALPHA_LAYER_SAVE_FLAG, MATRIX_SAVE_FLAG
Constructor and Description |
---|
PDFCanvas(Bitmap bitmap)
Not supported; throws UnsupportedOperationException
|
PDFCanvas(PDFPage page)
Construct a canvas for the specified page size
|
Modifier and Type | Method and Description |
---|---|
boolean |
clipPath(Path path)
Intersect the current clip with the specified path.
|
boolean |
clipPath(Path path,
Region.Op op)
Not supported; throws UnsupportedOperationException if called.
|
boolean |
clipRect(float left,
float top,
float right,
float bottom)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
|
boolean |
clipRect(float left,
float top,
float right,
float bottom,
Region.Op op)
Modify the current clip with the specified rectangle, which is expressed in local coordinates.
|
boolean |
clipRect(int left,
int top,
int right,
int bottom)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
|
boolean |
clipRect(Rect rect)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
|
boolean |
clipRect(RectF rect)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
|
boolean |
clipRect(RectF rect,
Region.Op op)
Modify the current clip with the specified rectangle.
|
boolean |
clipRect(Rect rect,
Region.Op op)
Modify the current clip with the specified rectangle.
|
boolean |
clipRegion(Region region)
Not supported; throws UnsupportedOperationException if called.
|
boolean |
clipRegion(Region region,
Region.Op op)
Not supported; throws UnsupportedOperationException if called.
|
void |
concat(Matrix matrix)
Preconcat the current matrix with the specified matrix.
|
void |
drawArc(RectF oval,
float startAngle,
float sweepAngle,
boolean useCenter,
Paint paint)
Draw the specified arc, which will be scaled to fit inside the specified oval.
|
void |
drawARGB(int a,
int r,
int g,
int b)
Fill the entire page (restricted to the current clip) with the specified ARGB color.
|
void |
drawBitmap(Bitmap bitmap,
float left,
float top,
Paint paint)
Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the
current matrix.
|
void |
drawBitmap(Bitmap bitmap,
Matrix transformMatrix,
Paint paint)
Draw the bitmap using the specified matrix.
|
void |
drawBitmap(Bitmap bitmap,
Rect src,
RectF dst,
Paint paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
|
void |
drawBitmap(Bitmap bitmap,
Rect src,
Rect dst,
Paint paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
|
void |
drawBitmap(int[] colors,
int offset,
int stride,
float x,
float y,
int width,
int height,
boolean hasAlpha,
Paint paint)
Treat the specified array of colors as a bitmap, and draw it.
|
void |
drawBitmap(int[] colors,
int offset,
int stride,
int x,
int y,
int width,
int height,
boolean hasAlpha,
Paint paint)
Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
|
void |
drawBitmapMesh(Bitmap bitmap,
int meshWidth,
int meshHeight,
float[] verts,
int vertOffset,
int[] colors,
int colorOffset,
Paint paint)
Draw the bitmap through the mesh, where mesh vertices are evenly distributed across the bitmap.
|
void |
drawCircle(float cx,
float cy,
float radius,
Paint paint)
Draw the specified circle using the specified paint.
|
void |
drawColor(int color)
Fill the entire page (restricted to the current clip) with the specified color.
|
void |
drawColor(int color,
PorterDuff.Mode mode)
Fill the entire page (restricted to the current clip) with the specified color and porter-duff xfermode.
|
void |
drawLine(float startX,
float startY,
float stopX,
float stopY,
Paint paint)
Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.
|
void |
drawLines(float[] pts,
int offset,
int count,
Paint paint)
Draw a series of lines.
|
void |
drawLines(float[] pts,
Paint paint)
Helper method for drawLines for the common case where all points are to be used.
|
void |
drawOval(RectF oval,
Paint paint)
Draw the specified oval using the specified paint.
|
void |
drawPaint(Paint paint)
Fill the entire page (restricted to the current clip) with the specified paint.
|
void |
drawPatch(Bitmap bitmap,
byte[] chunks,
RectF dst,
Paint paint)
Not supported; throws UnsupportedOperationException if called.
|
void |
drawPath(Path path,
Paint paint)
Not supported; throws UnsupportedOperationException if called.
|
void |
drawPicture(Picture picture)
Currently unsupported; throws UnsupportedOperationException if called.
|
void |
drawPicture(Picture picture,
Rect dst)
Currently unsupported; throws UnsupportedOperationException if called.
|
void |
drawPicture(Picture picture,
RectF dst)
Currently unsupported; throws UnsupportedOperationException if called.
|
void |
drawPoint(float x,
float y,
Paint paint)
Helper for drawPoints() for drawing a single point.
|
void |
drawPoints(float[] pts,
int offset,
int count,
Paint paint)
Draw a series of points.
|
void |
drawPoints(float[] pts,
Paint paint)
Helper for drawPoints() that assumes you want to draw the entire array
|
void |
drawPosText(char[] text,
int index,
int count,
float[] pos,
Paint paint)
Draw the text in the array, with each character's origin specified by the pos array, using the typeface and size
in the specified Paint.
|
void |
drawPosText(String text,
float[] pos,
Paint paint)
Draw the text in the array, with each character's origin specified by the pos array, using the typeface and size
in the specified Paint.
|
void |
drawRect(float left,
float top,
float right,
float bottom,
Paint paint)
Draw the specified Rect using the specified paint.
|
void |
drawRect(RectF r,
Paint paint)
Draw the specified Rect using the specified paint.
|
void |
drawRect(Rect r,
Paint paint)
Draw the specified Rect using the specified Paint.
|
void |
drawRGB(int r,
int g,
int b)
Fill the entire page (restricted to the current clip) with the specified RGB color.
|
void |
drawRoundRect(RectF rect,
float rx,
float ry,
Paint paint)
Draw the specified round-rect using the specified paint.
|
void |
drawText(char[] text,
int index,
int count,
float x,
float y,
Paint paint)
Draw the text, with origin at (x,y), using the typeface and size in the specified paint.
|
void |
drawText(CharSequence text,
int start,
int end,
float x,
float y,
Paint paint)
Draw the specified range of text, specified by start/end, with its origin at (x,y), using the typeface and size
in the specified paint.
|
void |
drawText(String text,
float x,
float y,
Paint paint)
Draw the text, with origin at (x,y), using the typeface and size in the specified paint.
|
void |
drawText(String text,
int start,
int end,
float x,
float y,
Paint paint)
Draw the text, with origin at (x,y), using the typeface and size in the specified paint.
|
void |
drawTextOnPath(char[] text,
int index,
int count,
Path path,
float hOffset,
float vOffset,
Paint paint)
Draw the text, with origin at (x,y), along the specified path, using the typeface and size in the specified
Paint.
|
void |
drawTextOnPath(String text,
Path path,
float hOffset,
float vOffset,
Paint paint)
Draw the text, with origin at (x,y), along the specified path, using the typeface and size in the specified
Paint.
|
void |
drawTextRun(char[] text,
int index,
int count,
int contextIndex,
int contextCount,
float x,
float y,
int dir,
Paint paint)
Currently unsupported; throws UnsupportedOperationException if called.
|
void |
drawTextRun(CharSequence text,
int start,
int end,
int contextStart,
int contextEnd,
float x,
float y,
int dir,
Paint paint)
Currently unsupported; throws UnsupportedOperationException if called.
|
void |
drawVertices(Canvas.VertexMode mode,
int vertexCount,
float[] verts,
int vertOffset,
float[] texs,
int texOffset,
int[] colors,
int colorOffset,
short[] indices,
int indexOffset,
int indexCount,
Paint paint)
Draw the array of vertices, interpreted as triangles (based on mode).
|
boolean |
getClipBounds(Rect bounds)
Retrieve the clip bounds, returning true if they are non-empty.
|
int |
getDensity()
Returns the target density of the canvas.
|
DrawFilter |
getDrawFilter()
Not supported; throws UnsupportedOperationException if called.
|
int |
getHeight()
Returns the imageable height of the current page
|
void |
getMatrix(Matrix ctm)
Return, in ctm, the current transformation matrix.
|
int |
getMaximumBitmapHeight()
Returns the maximum allowed height for bitmaps drawn with this canvas.
|
int |
getMaximumBitmapWidth()
Returns the maximum allowed width for bitmaps drawn with this canvas.
|
int |
getSaveCount()
Returns the number of matrix/clip states on the Canvas' private stack.
|
int |
getWidth()
Returns the imageable width of the current page
|
boolean |
isHardwareAccelerated()
Indicates whether this Canvas uses hardware acceleration - PDFCanvas does not.
|
boolean |
isOpaque()
Return true if the device that the current layer draws into is opaque (i.e.
|
boolean |
quickReject(float left,
float top,
float right,
float bottom,
PDFCanvas.EdgeType type)
Not supported, so always returns false.
|
boolean |
quickReject(Path path,
PDFCanvas.EdgeType type)
Not supported, so always returns false.
|
boolean |
quickReject(RectF rect,
PDFCanvas.EdgeType type)
Not supported, so always returns false.
|
void |
restore()
This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state
since the last save call.
|
void |
restoreToCount(int saveCount)
Efficient way to pop any calls to save() that happened after the save count reached saveCount.
|
void |
rotate(float degrees)
Preconcat the current matrix with the specified rotation.
|
int |
save()
Saves the current matrix and clip onto a private stack.
|
int |
save(int saveFlags)
Based on saveFlags, can save the current matrix and clip onto a private stack.
|
int |
saveLayer(float left,
float top,
float right,
float bottom,
Paint paint,
int saveFlags)
This behaves the same as save(), and all arguments are ignored.
|
int |
saveLayer(RectF bounds,
Paint paint,
int saveFlags)
This behaves the same as save(), and all arguments are ignored.
|
int |
saveLayerAlpha(float left,
float top,
float right,
float bottom,
int alpha,
int saveFlags)
This behaves the same as save(), and all arguments are ignored.
|
int |
saveLayerAlpha(RectF bounds,
int alpha,
int saveFlags)
This behaves the same as save(), and all arguments are ignored.
|
void |
scale(float sx,
float sy)
Preconcat the current matrix with the specified scale.
|
void |
setBitmap(Bitmap bitmap)
Not supported; throws UnsupportedOperationException
|
void |
setDensity(int density)
Specifies the density for this Canvas' backing bitmap.
|
void |
setDrawFilter(DrawFilter filter)
Not supported; throws UnsupportedOperationException if called.
|
void |
setMatrix(Matrix matrix)
Completely replace the current matrix with the specified matrix.
|
void |
setScreenDensity(int density)
Not supported; ignored.
|
void |
setViewport(int width,
int height)
Set the viewport dimensions if this canvas is GL based.
|
void |
skew(float sx,
float sy)
Preconcat the current matrix with the specified skew.
|
void |
translate(float dx,
float dy)
Preconcat the current matrix with the specified translation
|
getClipBounds, getMatrix, quickReject, quickReject, quickReject, rotate, scale
public static final int PDF_STROKE_CAP_BUTT
public static final int PDF_STROKE_CAP_ROUND
public static final int PDF_STROKE_CAP_PROJECTING_SQUARE
public static final int PDF_STROKE_JOIN_MITER
public static final int PDF_STROKE_JOIN_ROUND
public static final int PDF_STROKE_JOIN_BEVEL
public static final int DIRECTION_LTR
public static final int DIRECTION_RTL
public PDFCanvas(PDFPage page)
page
- public PDFCanvas(Bitmap bitmap)
public boolean isHardwareAccelerated()
isHardwareAccelerated
in class Canvas
public void setBitmap(Bitmap bitmap)
public void setViewport(int width, int height)
width
- The width of the viewportheight
- The height of the viewportpublic boolean isOpaque()
public int getWidth()
public int getHeight()
public int getDensity()
Returns the target density of the canvas.
getDensity
in class Canvas
setDensity(int)
,
Bitmap.getDensity()
public void setDensity(int density)
Specifies the density for this Canvas' backing bitmap. This modifies the target density of the canvas itself, as
well as the density of its backing bitmap via Bitmap.setDensity(int)
.
setDensity
in class Canvas
density
- The new target density of the canvas, which is used to determine the scaling factor when drawing a
bitmap into it. Use Bitmap.DENSITY_NONE
to disable bitmap scaling.getDensity()
,
Bitmap.setDensity(int)
public void setScreenDensity(int density)
density
- public int getMaximumBitmapWidth()
getMaximumBitmapWidth
in class Canvas
getMaximumBitmapHeight()
public int getMaximumBitmapHeight()
getMaximumBitmapHeight
in class Canvas
getMaximumBitmapWidth()
public int save()
public int save(int saveFlags)
public int saveLayer(RectF bounds, Paint paint, int saveFlags)
public int saveLayer(float left, float top, float right, float bottom, Paint paint, int saveFlags)
public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags)
saveLayerAlpha
in class Canvas
bounds
- Ignoredalpha
- IgnoredsaveFlags
- Ignoredpublic int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int saveFlags)
saveLayerAlpha
in class Canvas
public void restore()
public int getSaveCount()
getSaveCount
in class Canvas
public void restoreToCount(int saveCount)
restoreToCount
in class Canvas
saveCount
- The save level to restore to.public void translate(float dx, float dy)
public void scale(float sx, float sy)
public void rotate(float degrees)
public void skew(float sx, float sy)
public void concat(Matrix matrix)
public void setMatrix(Matrix matrix)
public void getMatrix(Matrix ctm)
public boolean clipRect(RectF rect, Region.Op op)
public boolean clipRect(Rect rect, Region.Op op)
public boolean clipRect(RectF rect)
public boolean clipRect(Rect rect)
public boolean clipRect(float left, float top, float right, float bottom, Region.Op op)
clipRect
in class Canvas
left
- The left side of the rectangle to intersect with the current cliptop
- The top of the rectangle to intersect with the current clipright
- The right side of the rectangle to intersect with the current clipbottom
- The bottom of the rectangle to intersect with the current clipop
- How the clip is modifiedpublic boolean clipRect(float left, float top, float right, float bottom)
clipRect
in class Canvas
left
- The left side of the rectangle to intersect with the current cliptop
- The top of the rectangle to intersect with the current clipright
- The right side of the rectangle to intersect with the current clipbottom
- The bottom of the rectangle to intersect with the current clippublic boolean clipRect(int left, int top, int right, int bottom)
clipRect
in class Canvas
left
- The left side of the rectangle to intersect with the current cliptop
- The top of the rectangle to intersect with the current clipright
- The right side of the rectangle to intersect with the current clipbottom
- The bottom of the rectangle to intersect with the current clippublic boolean clipPath(Path path, Region.Op op)
public boolean clipPath(Path path)
public boolean clipRegion(Region region, Region.Op op)
clipRegion
in class Canvas
region
- The region to operate on the current clip, based on opop
- How the clip is modifiedpublic boolean clipRegion(Region region)
clipRegion
in class Canvas
region
- The region to operate on the current clip, based on oppublic DrawFilter getDrawFilter()
getDrawFilter
in class Canvas
public void setDrawFilter(DrawFilter filter)
setDrawFilter
in class Canvas
public boolean quickReject(RectF rect, PDFCanvas.EdgeType type)
rect
- Ignoredtype
- Ignoredpublic boolean quickReject(Path path, PDFCanvas.EdgeType type)
path
- Ignoredtype
- Ignoredpublic boolean quickReject(float left, float top, float right, float bottom, PDFCanvas.EdgeType type)
left
- Ignoredtop
- Ignoredright
- Ignoredbottom
- Ignoredtype
- Ignoredpublic boolean getClipBounds(Rect bounds)
getClipBounds
in class Canvas
bounds
- Return the clip bounds here. If it is null, ignore it but still return true if the current clip is
non-empty.public void drawRGB(int r, int g, int b)
public void drawARGB(int a, int r, int g, int b)
drawARGB
in class Canvas
a
- alpha component (0..255) of the color to draw onto the canvasr
- red component (0..255) of the color to draw onto the canvasg
- green component (0..255) of the color to draw onto the canvasb
- blue component (0..255) of the color to draw onto the canvaspublic void drawColor(int color)
public void drawColor(int color, PorterDuff.Mode mode)
public void drawPaint(Paint paint)
public void drawPoints(float[] pts, int offset, int count, Paint paint)
drawPoints
in class Canvas
pts
- Array of points to draw [x0 y0 x1 y1 x2 y2 ...]offset
- Number of values to skip before starting to draw.count
- The number of values to process, after skipping offset of them. Since one point uses two values, the
number of "points" that are drawn is really (count >> 1).paint
- The paint used to draw the pointspublic void drawPoints(float[] pts, Paint paint)
drawPoints
in class Canvas
public void drawPoint(float x, float y, Paint paint)
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
public void drawLines(float[] pts, int offset, int count, Paint paint)
drawLines
in class Canvas
pts
- Array of points to draw [x0 y0 x1 y1 x2 y2 ...]offset
- Number of values in the array to skip before drawing.count
- The number of values in the array to process, after skipping "offset" of them. Since each line uses 4
values, the number of "lines" that are drawn is really (count >> 2).paint
- The paint used to draw the pointspublic void drawLines(float[] pts, Paint paint)
public void drawRect(RectF r, Paint paint)
public void drawRect(Rect r, Paint paint)
public void drawRect(float left, float top, float right, float bottom, Paint paint)
public void drawOval(RectF oval, Paint paint)
public void drawCircle(float cx, float cy, float radius, Paint paint)
drawCircle
in class Canvas
cx
- The x-coordinate of the center of the cirle to be drawncy
- The y-coordinate of the center of the cirle to be drawnradius
- The radius of the cirle to be drawnpaint
- The paint used to draw the circlepublic void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
Draw the specified arc, which will be scaled to fit inside the specified oval.
If the start angle is negative or >= 360, the start angle is treated as start angle modulo 360.
If the sweep angle is >= 360, then the oval is drawn completely. Note that this differs slightly from SkPath::arcTo, which treats the sweep angle modulo 360. If the sweep angle is negative, the sweep angle is treated as sweep angle modulo 360
The arc is drawn clockwise. An angle of 0 degrees correspond to the geometric angle of 0 degrees (3 o'clock on a watch.)
drawArc
in class Canvas
oval
- The bounds of oval used to define the shape and size of the arcstartAngle
- Starting angle (in degrees) where the arc beginssweepAngle
- Sweep angle (in degrees) measured clockwiseuseCenter
- If true, include the center of the oval in the arc, and close it if it is being stroked. This will
draw a wedgepaint
- The paint used to draw the arcpublic void drawRoundRect(RectF rect, float rx, float ry, Paint paint)
drawRoundRect
in class Canvas
rect
- The rectangular bounds of the roundRect to be drawnrx
- The x-radius of the oval used to round the cornersry
- The y-radius of the oval used to round the cornerspaint
- The paint used to draw the roundRectpublic void drawPath(Path path, Paint paint)
public void drawPatch(Bitmap bitmap, byte[] chunks, RectF dst, Paint paint)
bitmap
- The bitmap to draw as an N-patchchunks
- The patches information (matches the native struct Res_png_9patch)dst
- The destination rectangle.paint
- The paint to draw the bitmap with. may be nullpublic void drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
If the bitmap and canvas have different densities, this function will take care of automatically scaling the bitmap to draw at the same density as the canvas.
drawBitmap
in class Canvas
bitmap
- The bitmap to be drawnleft
- The position of the left side of the bitmap being drawntop
- The position of the top side of the bitmap being drawnpaint
- The paint used to draw the bitmap (may be null)public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
This function ignores the density associated with the bitmap. This is because the source and destination rectangle coordinate spaces are in their respective densities, so must already have the appropriate scaling factor applied.
drawBitmap
in class Canvas
bitmap
- The bitmap to be drawnsrc
- May be null. The subset of the bitmap to be drawndst
- The rectangle that the bitmap will be scaled/translated to fit intopaint
- May be null. The paint used to draw the bitmappublic void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
This function ignores the density associated with the bitmap. This is because the source and destination rectangle coordinate spaces are in their respective densities, so must already have the appropriate scaling factor applied.
drawBitmap
in class Canvas
bitmap
- The bitmap to be drawnsrc
- May be null. The subset of the bitmap to be drawndst
- The rectangle that the bitmap will be scaled/translated to fit intopaint
- May be null. The paint used to draw the bitmappublic void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, Paint paint)
drawBitmap
in class Canvas
colors
- Array of colors representing the pixels of the bitmapoffset
- Offset into the array of colors for the first pixelstride
- The number of colors in the array between rows (must be >= width or <= -width).x
- The X coordinate for where to draw the bitmapy
- The Y coordinate for where to draw the bitmapwidth
- The width of the bitmapheight
- The height of the bitmaphasAlpha
- True if the alpha channel of the colors contains valid values. If false, the alpha byte is ignored
(assumed to be 0xFF for every pixel).paint
- May be null. The paint used to draw the bitmappublic void drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)
drawBitmap
in class Canvas
public void drawBitmap(Bitmap bitmap, Matrix transformMatrix, Paint paint)
drawBitmap
in class Canvas
bitmap
- The bitmap to drawmatrix
- The matrix used to transform the bitmap when it is drawnpaint
- May be null. The paint used to draw the bitmappublic void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint)
drawBitmapMesh
in class Canvas
bitmap
- The bitmap to draw using the meshmeshWidth
- The number of columns in the mesh. Nothing is drawn if this is 0meshHeight
- The number of rows in the mesh. Nothing is drawn if this is 0verts
- Array of x,y pairs, specifying where the mesh should be drawn. There must be at least (meshWidth+1) *
(meshHeight+1) * 2 + meshOffset values in the arrayvertOffset
- Number of verts elements to skip before drawingcolors
- May be null. Specifies a color at each vertex, which is interpolated across the cell, and whose values
are multiplied by the corresponding bitmap colors. If not null, there must be at least (meshWidth+1) *
(meshHeight+1) + colorOffset values in the array.colorOffset
- Number of color elements to skip before drawingpaint
- May be null. The paint used to draw the bitmappublic void drawVertices(Canvas.VertexMode mode, int vertexCount, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, int indexOffset, int indexCount, Paint paint)
The VertexMode determines how the subsequent points in the sequence of vertices are interpreted.
drawVertices
in class Canvas
mode
- How to interpret the array of verticesvertexCount
- The number of values in the vertices array (and corresponding texs and colors arrays if non-null).
Each logical vertex is two values (x, y), vertexCount must be a multiple of 2.verts
- Array of vertices for the meshvertOffset
- Number of values in the verts to skip before drawing.texs
- Currently ignored (may be null)texOffset
- Currently ignoredcolors
- Specifies a color for each vertex, to be interpolated across the triangle.colorOffset
- Number of values in colors to skip before drawing.indices
- Currently ignored (may be null)indexCount
- Currently ignoredpaint
- Currently ignored (may be null)public void drawText(char[] text, int index, int count, float x, float y, Paint paint)
public void drawText(String text, float x, float y, Paint paint)
public void drawText(String text, int start, int end, float x, float y, Paint paint)
drawText
in class Canvas
text
- The text to be drawnstart
- The index of the first character in text to drawend
- (end - 1) is the index of the last character in text to drawx
- The x-coordinate of the origin of the text being drawny
- The y-coordinate of the origin of the text being drawnpaint
- The paint used for the text (e.g. color, size, style)public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint)
drawText
in class Canvas
text
- The text to be drawnstart
- The index of the first character in text to drawend
- (end - 1) is the index of the last character in text to drawx
- The x-coordinate of origin for where to draw the texty
- The y-coordinate of origin for where to draw the textpaint
- The paint used for the text (e.g. color, size, style)public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, float x, float y, int dir, Paint paint)
text
- the text to renderindex
- the start of the text to rendercount
- the count of chars to rendercontextIndex
- the start of the context for shaping. Must be no greater than index.contextCount
- the number of characters in the context for shaping. ContexIndex + contextCount must be no less than
index + count.x
- the x position at which to draw the texty
- the y position at which to draw the textdir
- the run direction, either DIRECTION_LTR
or DIRECTION_RTL
.paint
- the paintpublic void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, float x, float y, int dir, Paint paint)
text
- the text to renderstart
- the start of the text to render. Data before this position can be used for shaping context.end
- the end of the text to render. Data at or after this position can be used for shaping context.x
- the x position at which to draw the texty
- the y position at which to draw the textdir
- the run direction, either 0 for LTR or 1 for RTL.paint
- the paintpublic void drawPosText(char[] text, int index, int count, float[] pos, Paint paint)
drawPosText
in class Canvas
text
- The text to be drawnindex
- The index of the first character to drawcount
- The number of characters to draw, starting from index.pos
- Array of [x,y] positions, used to position each characterpaint
- The paint used for the text (e.g. color, size, style)public void drawPosText(String text, float[] pos, Paint paint)
drawPosText
in class Canvas
text
- The text to be drawnpos
- Array of [x,y] positions, used to position each characterpaint
- The paint used for the text (e.g. color, size, style)public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)
drawTextOnPath
in class Canvas
text
- The text to be drawnpath
- The path the text should follow for its baselinehOffset
- The distance along the path to add to the text's starting positionvOffset
- The distance above(-) or below(+) the path to position the textpaint
- The paint used for the text (e.g. color, size, style)public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)
drawTextOnPath
in class Canvas
text
- The text to be drawnpath
- The path the text should follow for its baselinehOffset
- The distance along the path to add to the text's starting positionvOffset
- The distance above(-) or below(+) the path to position the textpaint
- The paint used for the text (e.g. color, size, style)public void drawPicture(Picture picture)
drawPicture
in class Canvas
picture
- The picture to be drawnpublic void drawPicture(Picture picture, RectF dst)
drawPicture
in class Canvas
public void drawPicture(Picture picture, Rect dst)
drawPicture
in class Canvas