public final class Graphics extends Object
Represents the graphics according to the graphics engine used in the current assembly.
This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
Constructor and Description |
---|
Graphics(Image sourceImage)
Initializes a new instance of the
Graphics class. |
Modifier and Type | Method and Description |
---|---|
void |
beginUpdate()
Starts caching of the following graphics operations.
|
void |
clear(Color color)
Clears the graphics surface using the specified color.
|
void |
drawArc(Pen pen,
float x,
float y,
float width,
float height,
float startAngle,
float sweepAngle)
Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.
|
void |
drawArc(Pen pen,
int x,
int y,
int width,
int height,
int startAngle,
int sweepAngle)
Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.
|
void |
drawArc(Pen pen,
RectangleF rect,
float startAngle,
float sweepAngle)
Draws an arc representing a portion of an ellipse specified by a
RectangleF structure. |
void |
drawArc(Pen pen,
Rectangle rect,
float startAngle,
float sweepAngle)
Draws an arc representing a portion of an ellipse specified by a
Rectangle structure. |
void |
drawBezier(Pen pen,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x4,
float y4)
Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.
|
void |
drawBezier(Pen pen,
PointF pt1,
PointF pt2,
PointF pt3,
PointF pt4)
Draws a Bézier spline defined by four
PointF structures. |
void |
drawBezier(Pen pen,
Point pt1,
Point pt2,
Point pt3,
Point pt4)
Draws a Bézier spline defined by four
Point structures. |
void |
drawBeziers(Pen pen,
Point[] points)
Draws a series of Bézier splines from an array of
Point structures. |
void |
drawBeziers(Pen pen,
PointF[] points)
Draws a series of Bézier splines from an array of
PointF structures. |
void |
drawClosedCurve(Pen pen,
Point[] points)
Draws a closed cardinal spline defined by an array of
Point structures. |
void |
drawClosedCurve(Pen pen,
Point[] points,
float tension)
Draws a closed cardinal spline defined by an array of
Point structures using a specified tension. |
void |
drawClosedCurve(Pen pen,
PointF[] points)
Draws a closed cardinal spline defined by an array of
PointF structures. |
void |
drawClosedCurve(Pen pen,
PointF[] points,
float tension)
Draws a closed cardinal spline defined by an array of
PointF structures using a specified tension. |
void |
drawCurve(Pen pen,
Point[] points)
Draws a cardinal spline through a specified array of
Point structures. |
void |
drawCurve(Pen pen,
Point[] points,
float tension)
Draws a cardinal spline through a specified array of
Point structures using a specified tension. |
void |
drawCurve(Pen pen,
Point[] points,
int offset,
int numberOfSegments,
float tension)
Draws a cardinal spline through a specified array of
Point structures using a specified tension. |
void |
drawCurve(Pen pen,
PointF[] points)
Draws a cardinal spline through a specified array of
PointF structures. |
void |
drawCurve(Pen pen,
PointF[] points,
float tension)
Draws a cardinal spline through a specified array of
PointF structures using a specified tension. |
void |
drawCurve(Pen pen,
PointF[] points,
int offset,
int numberOfSegments)
Draws a cardinal spline through a specified array of
PointF structures. |
void |
drawCurve(Pen pen,
PointF[] points,
int offset,
int numberOfSegments,
float tension)
Draws a cardinal spline through a specified array of
PointF structures using a specified tension. |
void |
drawEllipse(Pen pen,
float x,
float y,
float width,
float height)
Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.
|
void |
drawEllipse(Pen pen,
int x,
int y,
int width,
int height)
Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.
|
void |
drawEllipse(Pen pen,
Rectangle rect)
Draws an ellipse specified by a bounding
Rectangle structure. |
void |
drawEllipse(Pen pen,
RectangleF rect)
Draws an ellipse defined by a bounding
RectangleF . |
void |
drawImage(Image sourceImage,
float x,
float y)
Draws the specified
Image , using its original physical size, at the specified location. |
void |
drawImage(Image sourceImage,
float x,
float y,
float width,
float height)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
int x,
int y)
Draws the specified image, using its original physical size, at the location specified by a coordinate pair.
|
void |
drawImage(Image sourceImage,
int x,
int y,
int width,
int height)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
Point point)
Draws the specified
Image , using its original physical size, at the specified location. |
void |
drawImage(Image image,
Point[] destPoints)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image image,
Point[] destPoints,
Rectangle srcRect)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image image,
Point[] destPoints,
Rectangle srcRect,
int srcUnit)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image image,
Point[] destPoints,
Rectangle srcRect,
int srcUnit,
ImageAttributes imageAttributes)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
PointF point)
Draws the specified
Image , using its original physical size, at the specified location. |
void |
drawImage(Image image,
PointF[] destPoints)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image image,
PointF[] destPoints,
RectangleF srcRect)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image image,
PointF[] destPoints,
RectangleF srcRect,
int srcUnit)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image image,
PointF[] destPoints,
RectangleF srcRect,
int srcUnit,
ImageAttributes imageAttributes)
Draws the specified portion of the specified
image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
Rectangle rect)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
RectangleF rect)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
RectangleF rectDestination,
int graphicsUnit)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
RectangleF rectDestination,
int graphicsUnit,
ImageAttributes imageAttributes)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
RectangleF rectSource,
RectangleF rectDestination,
int graphicsUnit)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
RectangleF rectSource,
RectangleF rectDestination,
int graphicsUnit,
ImageAttributes imageAttributes)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
Rectangle rectDestination,
int graphicsUnit)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
Rectangle rectDestination,
int graphicsUnit,
ImageAttributes imageAttributes)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
Rectangle rectSource,
Rectangle rectDestination,
int graphicsUnit)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImage(Image sourceImage,
Rectangle rectSource,
Rectangle rectDestination,
int graphicsUnit,
ImageAttributes imageAttributes)
Draws the specified
Image at the specified location and with the specified size. |
void |
drawImageUnscaled(Image sourceImage,
int x,
int y)
Draws the specified image using its original physical size at the location specified by a coordinate pair.
|
void |
drawImageUnscaled(Image sourceImage,
int x,
int y,
int width,
int height)
Draws a specified image using its original physical size at a specified location.
|
void |
drawImageUnscaled(Image sourceImage,
Point point)
Draws a specified image using its original physical size at a specified location.
|
void |
drawImageUnscaled(Image sourceImage,
Rectangle rect)
Draws a specified image using its original physical size at a specified location.
|
void |
drawImageUnscaledAndClipped(Image sourceImage,
Rectangle rect)
Draws the specified image without scaling and clips it, if necessary, to fit in the specified rectangle.
|
void |
drawLine(Pen pen,
float x1,
float y1,
float x2,
float y2)
Draws a line connecting the two points specified by the coordinate pairs.
|
void |
drawLine(Pen pen,
int x1,
int y1,
int x2,
int y2)
Draws a line connecting the two points specified by the coordinate pairs.
|
void |
drawLine(Pen pen,
PointF point1,
PointF point2)
Draws a line connecting two
PointF structures. |
void |
drawLine(Pen pen,
Point point1,
Point point2)
Draws a line connecting two
Point structures. |
void |
drawLines(Pen pen,
Point[] points)
Draws a series of line segments that connect an array of
Point structures. |
void |
drawLines(Pen pen,
PointF[] points)
Draws a series of line segments that connect an array of
PointF structures. |
void |
drawPath(Pen pen,
GraphicsPath path)
Draws a
com.aspose.imaging.graphicsPath . |
void |
drawPie(Pen pen,
float x,
float y,
float width,
float height,
float startAngle,
float sweepAngle)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
|
void |
drawPie(Pen pen,
int x,
int y,
int width,
int height,
int startAngle,
int sweepAngle)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
|
void |
drawPie(Pen pen,
RectangleF rect,
float startAngle,
float sweepAngle)
Draws a pie shape defined by an ellipse specified by a
RectangleF structure and two radial lines. |
void |
drawPie(Pen pen,
Rectangle rect,
float startAngle,
float sweepAngle)
Draws a pie shape defined by an ellipse specified by a
Rectangle structure and two radial lines. |
void |
drawPolygon(Pen pen,
Point[] points)
Draws a polygon defined by an array of
Point structures. |
void |
drawPolygon(Pen pen,
PointF[] points)
Draws a polygon defined by an array of
PointF structures. |
void |
drawRectangle(Pen pen,
float x,
float y,
float width,
float height)
Draws a rectangle specified by a coordinate pair, a width, and a height.
|
void |
drawRectangle(Pen pen,
int x,
int y,
int width,
int height)
Draws a rectangle specified by a coordinate pair, a width, and a height.
|
void |
drawRectangle(Pen pen,
Rectangle rect)
Draws a rectangle specified by a
Rectangle structure. |
void |
drawRectangle(Pen pen,
RectangleF rect)
Draws a rectangle specified by a
RectangleF structure. |
void |
drawRectangles(Pen pen,
Rectangle[] rects)
Draws a series of rectangles specified by
Rectangle structures. |
void |
drawRectangles(Pen pen,
RectangleF[] rects)
Draws a series of rectangles specified by
RectangleF structures. |
void |
drawString(String s,
Font font,
Brush brush,
float x,
float y)
Draws the specified text string at the specified location with the specified
com.aspose.imaging.Brush and com.aspose.imaging.Font objects. |
void |
drawString(String s,
Font font,
Brush brush,
float x,
float y,
StringFormat format)
Draws the specified text string at the specified location with the specified
com.aspose.imaging.Brush and com.aspose.imaging.Font objects using the formatting attributes of the specified com.aspose.imaging.stringFormat . |
void |
drawString(String s,
Font font,
Brush brush,
PointF point)
Draws the specified text string at the specified location with the specified
com.aspose.imaging.Brush and com.aspose.imaging.Font objects. |
void |
drawString(String s,
Font font,
Brush brush,
PointF point,
StringFormat format)
Draws the specified text string at the specified location with the specified
com.aspose.imaging.Brush and com.aspose.imaging.Font objects using the formatting attributes of the specified com.aspose.imaging.stringFormat . |
void |
drawString(String s,
Font font,
Brush brush,
RectangleF layoutRectangle)
Draws the specified text string in the specified rectangle with the specified
com.aspose.imaging.Brush and com.aspose.imaging.Font objects. |
void |
drawString(String s,
Font font,
Brush brush,
RectangleF layoutRectangle,
StringFormat format)
Draws the specified text string in the specified rectangle with the specified
com.aspose.imaging.Brush and com.aspose.imaging.Font objects using the formatting attributes of the specified com.aspose.imaging.stringFormat . |
void |
endUpdate()
Finishes caching of the graphics operations started after BeginUpdate was called.
|
void |
fillClosedCurve(Brush brush,
Point[] points)
Fills the interior of a closed cardinal spline curve defined by an array of
com.aspose.imaging.Point structures. |
void |
fillClosedCurve(Brush brush,
Point[] points,
int fillmode)
Fills the interior of a closed cardinal spline curve defined by an array of
com.aspose.imaging.Point structures using the specified fill mode. |
void |
fillClosedCurve(Brush brush,
Point[] points,
int fillmode,
float tension)
Fills the interior of a closed cardinal spline curve defined by an array of
com.aspose.imaging.Point structures using the specified fill mode and tension. |
void |
fillClosedCurve(Brush brush,
PointF[] points)
Fills the interior of a closed cardinal spline curve defined by an array of
com.aspose.imaging.PointF structures. |
void |
fillClosedCurve(Brush brush,
PointF[] points,
int fillmode)
Fills the interior of a closed cardinal spline curve defined by an array of
com.aspose.imaging.PointF structures using the specified fill mode. |
void |
fillClosedCurve(Brush brush,
PointF[] points,
int fillmode,
float tension)
Fills the interior of a closed cardinal spline curve defined by an array of
com.aspose.imaging.PointF structures using the specified fill mode and tension. |
void |
fillEllipse(Brush brush,
float x,
float y,
float width,
float height)
Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates, a width, and a height.
|
void |
fillEllipse(Brush brush,
int x,
int y,
int width,
int height)
Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates, a width, and a height.
|
void |
fillEllipse(Brush brush,
Rectangle rect)
Fills the interior of an ellipse defined by a bounding rectangle specified by a
com.aspose.imaging.Rectangle structure. |
void |
fillEllipse(Brush brush,
RectangleF rect)
Fills the interior of an ellipse defined by a bounding rectangle specified by a
com.aspose.imaging.RectangleF structure. |
void |
fillPath(Brush brush,
GraphicsPath path)
Fills the interior of a
com.aspose.imaging.graphicsPath . |
void |
fillPie(Brush brush,
float x,
float y,
float width,
float height,
float startAngle,
float sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates, a width, a height, and two radial lines.
|
void |
fillPie(Brush brush,
int x,
int y,
int width,
int height,
int startAngle,
int sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates, a width, a height, and two radial lines.
|
void |
fillPie(Brush brush,
RectangleF rect,
float startAngle,
float sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a
com.aspose.imaging.RectangleF structure and two radial lines. |
void |
fillPie(Brush brush,
Rectangle rect,
float startAngle,
float sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a
com.aspose.imaging.RectangleF structure and two radial lines. |
void |
fillPolygon(Brush brush,
Point[] points)
Fills the interior of a polygon defined by an array of points specified by
com.aspose.imaging.Point structures and FillMode.Alternate . |
void |
fillPolygon(Brush brush,
Point[] points,
int fillMode)
Fills the interior of a polygon defined by an array of points specified by
com.aspose.imaging.Point structures using the specified fill mode. |
void |
fillPolygon(Brush brush,
PointF[] points)
Fills the interior of a polygon defined by an array of points specified by
com.aspose.imaging.PointF structures and FillMode.Alternate . |
void |
fillPolygon(Brush brush,
PointF[] points,
int fillMode)
Fills the interior of a polygon defined by an array of points specified by
com.aspose.imaging.PointF structures using the specified fill mode. |
void |
fillRectangle(Brush brush,
float x,
float y,
float width,
float height)
Fills the interior of a rectangle specified by a pair of coordinates, a width and a height.
|
void |
fillRectangle(Brush brush,
int x,
int y,
int width,
int height)
Fills the interior of a rectangle specified by a pair of coordinates, a width and a height.
|
void |
fillRectangle(Brush brush,
Rectangle rect)
Fills the interior of a rectangle specified by a
Rectangle structure. |
void |
fillRectangle(Brush brush,
RectangleF rect)
Fills the interior of a rectangle specified by a
RectangleF structure. |
void |
fillRectangles(Brush brush,
Rectangle[] rects)
Fills the interiors of a series of rectangles specified by
Rectangle structures. |
void |
fillRectangles(Brush brush,
RectangleF[] rects)
Fills the interiors of a series of rectangles specified by
RectangleF structures. |
void |
fillRegion(Brush brush,
Region region)
Fills the interior of a
com.aspose.imaging.region . |
Region |
getClip()
Gets or sets the clip region.
|
int |
getCompositingQuality()
Gets or sets the compositing quality.
|
float |
getDpiX()
Gets the horizontal resolution of this com.aspose.imaging.graphics.
|
float |
getDpiY()
Gets the vertical resolution of this com.aspose.imaging.graphics.
|
Image |
getImage()
Gets the image.
|
int |
getInterpolationMode()
Gets or sets the interpolation mode.
|
float |
getPageScale()
Gets or sets the scaling between world units and page units for this com.aspose.imaging.graphics.
|
int |
getPageUnit()
Gets or sets the unit of measure used for page coordinates in this com.aspose.imaging.graphics.
|
int |
getSmoothingMode()
Gets or sets the smoothing mode.
|
int |
getTextRenderingHint()
Gets or sets the text rendering hint.
|
Matrix |
getTransform()
Gets or sets a copy of the geometric world transformation for this
com.aspose.imaging.graphics . |
boolean |
isInBeginUpdateCall()
Gets a value indicating whether graphics is in BeginUpdate call state.
|
void |
multiplyTransform(Matrix matrix)
Multiplies the
com.aspose.imaging.Matrix that represents the local geometric transform of this com.aspose.imaging.Graphics by the specified com.aspose.imaging.Matrix by prepending the specified com.aspose.imaging.matrix . |
void |
multiplyTransform(Matrix matrix,
int order)
Multiplies the
com.aspose.imaging.Matrix that represents the local geometric transform of this com.aspose.imaging.Graphics by the specified com.aspose.imaging.Matrix in the specified order. |
void |
resetTransform()
Resets the
com.aspose.imaging.graphics.Transform property to identity. |
void |
rotateTransform(float angle)
Rotates the local geometric transform by the specified amount.
|
void |
rotateTransform(float angle,
int order)
Rotates the local geometric transform by the specified amount in the specified order.
|
void |
scaleTransform(float sx,
float sy)
Scales the local geometric transform by the specified amounts.
|
void |
scaleTransform(float sx,
float sy,
int order)
Scales the local geometric transform by the specified amounts in the specified order.
|
void |
setClip(Region value)
Gets or sets the clip region.
|
void |
setCompositingQuality(int value)
Gets or sets the compositing quality.
|
void |
setInterpolationMode(int value)
Gets or sets the interpolation mode.
|
void |
setPageScale(float value)
Gets or sets the scaling between world units and page units for this com.aspose.imaging.graphics.
|
void |
setPageUnit(int value)
Gets or sets the unit of measure used for page coordinates in this com.aspose.imaging.graphics.
|
void |
setSmoothingMode(int value)
Gets or sets the smoothing mode.
|
void |
setTextRenderingHint(int value)
Gets or sets the text rendering hint.
|
void |
setTransform(Matrix value)
Gets or sets a copy of the geometric world transformation for this
com.aspose.imaging.graphics . |
void |
translateTransform(float dx,
float dy)
Translates the local geometric transform by the specified dimensions.
|
void |
translateTransform(float dx,
float dy,
int order)
Translates the local geometric transform by the specified dimensions in the specified order.
|
public Graphics(Image sourceImage)
Initializes a new instance of the Graphics
class.
sourceImage
- The source image.public float getDpiX()
Gets the horizontal resolution of this com.aspose.imaging.graphics.
public float getDpiY()
Gets the vertical resolution of this com.aspose.imaging.graphics.
public int getPageUnit()
Gets or sets the unit of measure used for page coordinates in this com.aspose.imaging.graphics.
public void setPageUnit(int value)
Gets or sets the unit of measure used for page coordinates in this com.aspose.imaging.graphics.
value
- The unit of measure used for page coordinates in this com.aspose.imaging.graphics.public float getPageScale()
Gets or sets the scaling between world units and page units for this com.aspose.imaging.graphics.
public void setPageScale(float value)
Gets or sets the scaling between world units and page units for this com.aspose.imaging.graphics.
value
- The scaling between world units and page units for this com.aspose.imaging.graphics.public Region getClip()
Gets or sets the clip region.
public void setClip(Region value)
Gets or sets the clip region.
value
- The clip region.public Matrix getTransform()
Gets or sets a copy of the geometric world transformation for this com.aspose.imaging.graphics
.
com.aspose.imaging.Matrix
that represents the geometric world transformation for this com.aspose.imaging.graphics
.public void setTransform(Matrix value)
Gets or sets a copy of the geometric world transformation for this com.aspose.imaging.graphics
.
value
- A copy of the com.aspose.imaging.Matrix
that represents the geometric world transformation for this com.aspose.imaging.graphics
.public boolean isInBeginUpdateCall()
Gets a value indicating whether graphics is in BeginUpdate call state.
True
if graphics is in BeginUpdate call state; otherwise, false
.public Image getImage()
Gets the image.
public int getCompositingQuality()
Gets or sets the compositing quality.
public void setCompositingQuality(int value)
Gets or sets the compositing quality.
value
- The compositing quality.public int getInterpolationMode()
Gets or sets the interpolation mode.
public void setInterpolationMode(int value)
Gets or sets the interpolation mode.
value
- The interpolation mode.public int getSmoothingMode()
Gets or sets the smoothing mode.
public void setSmoothingMode(int value)
Gets or sets the smoothing mode.
value
- The smoothing mode.public int getTextRenderingHint()
Gets or sets the text rendering hint.
public void setTextRenderingHint(int value)
Gets or sets the text rendering hint.
value
- The text rendering hint.public void resetTransform()
Resets the com.aspose.imaging.graphics.Transform
property to identity.
public void multiplyTransform(Matrix matrix)
Multiplies the com.aspose.imaging.Matrix
that represents the local geometric transform of this com.aspose.imaging.Graphics
by the specified com.aspose.imaging.Matrix
by prepending the specified com.aspose.imaging.matrix
.
matrix
- The com.aspose.imaging.Matrix
by which to multiply the geometric transform.public void multiplyTransform(Matrix matrix, int order)
Multiplies the com.aspose.imaging.Matrix
that represents the local geometric transform of this com.aspose.imaging.Graphics
by the specified com.aspose.imaging.Matrix
in the specified order.
matrix
- The com.aspose.imaging.Matrix
by which to multiply the geometric transform.order
- A com.aspose.imaging.MatrixOrder
that specifies in which order to multiply the two matrices.public void translateTransform(float dx, float dy)
Translates the local geometric transform by the specified dimensions. This method prepends the translation to the transform.
dx
- The value of the translation in x.dy
- The value of the translation in y.public void translateTransform(float dx, float dy, int order)
Translates the local geometric transform by the specified dimensions in the specified order.
dx
- The value of the translation in x.dy
- The value of the translation in y.order
- The order (prepend or append) in which to apply the translation.public void scaleTransform(float sx, float sy)
Scales the local geometric transform by the specified amounts. This method prepends the scaling matrix to the transform.
sx
- The amount by which to scale the transform in the x-axis direction.sy
- The amount by which to scale the transform in the y-axis direction.public void scaleTransform(float sx, float sy, int order)
Scales the local geometric transform by the specified amounts in the specified order.
sx
- The amount by which to scale the transform in the x-axis direction.sy
- The amount by which to scale the transform in the y-axis direction.order
- A com.aspose.imaging.MatrixOrder
that specifies whether to append or prepend the scaling matrix.public void rotateTransform(float angle)
Rotates the local geometric transform by the specified amount. This method prepends the rotation to the transform.
angle
- The angle of rotation.public void rotateTransform(float angle, int order)
Rotates the local geometric transform by the specified amount in the specified order.
angle
- The angle of rotation.order
- A com.aspose.imaging.MatrixOrder
that specifies whether to append or prepend the rotation matrix.public void beginUpdate()
Starts caching of the following graphics operations. The graphics effects applied afterwards will not be applied immediately instead the EndUpdate will cause applying all the effects at once.
Note the effects after BeginUpdate is called will not be applied in case EndUpdate is not called.
The following example shows how to set a memory limit when creating a PNG image and drawing complex graphics on it. The memory limit is the maximum allowed size (in megabytes) for all internal buffers.
String workDir = "c:\\temp\\"; final int ImageSize = 2000; com.aspose.imaging.ImageOptionsBase createOptions = new com.aspose.imaging.imageoptions.PngOptions(); com.aspose.imaging.Image image; try { createOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(workDir + "temporary.png")); createOptions.setBufferSizeHint(30); // Memory limit is 30 Mb image = com.aspose.imaging.Image.create(createOptions, ImageSize, ImageSize); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // You can use any graphic operations here, all of them will be performed within the established memory limit // For example: graphics.clear(com.aspose.imaging.Color.getLightSkyBlue()); graphics.drawLine(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 3f), 0, 0, image.getWidth(), image.getHeight()); } finally { image.close(); } } finally { createOptions.close(); } // A large number of graphic operations are also supported: final int OperationAreaSize = 10; createOptions = new com.aspose.imaging.imageoptions.PngOptions(); createOptions.setBufferSizeHint(30); // Memory limit is 30 Mb createOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(workDir + "temporary.png")); try { image = com.aspose.imaging.Image.create(createOptions, ImageSize, ImageSize); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); graphics.beginUpdate(); graphics.clear(com.aspose.imaging.Color.getLightSkyBlue()); int x, y; for (int column = 0; column * OperationAreaSize < ImageSize; column++) { for (int row = 0; row * OperationAreaSize < ImageSize; row++) { x = column * OperationAreaSize; y = row * OperationAreaSize; boolean reversed = (column + row) % 2 != 0; if (reversed) { graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed()), x + OperationAreaSize - 2, y, x, y + OperationAreaSize); } else { graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed()), x, y, x + OperationAreaSize - 2, y + OperationAreaSize); } } } // About 40k operations will be applied here, while they do not take up too much memory // (since they are already unloaded into the external file, and will be loaded from there one at a time) graphics.endUpdate(); } finally { image.close(); } } finally { createOptions.close(); }
public void endUpdate()
Finishes caching of the graphics operations started after BeginUpdate was called. The preceding graphics operations will be applied at once when calling this method.
The following example shows how to set a memory limit when creating a PNG image and drawing complex graphics on it. The memory limit is the maximum allowed size (in megabytes) for all internal buffers.
String workDir = "c:\\temp\\"; final int ImageSize = 2000; com.aspose.imaging.ImageOptionsBase createOptions = new com.aspose.imaging.imageoptions.PngOptions(); com.aspose.imaging.Image image; try { createOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(workDir + "temporary.png")); createOptions.setBufferSizeHint(30); // Memory limit is 30 Mb image = com.aspose.imaging.Image.create(createOptions, ImageSize, ImageSize); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // You can use any graphic operations here, all of them will be performed within the established memory limit // For example: graphics.clear(com.aspose.imaging.Color.getLightSkyBlue()); graphics.drawLine(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 3f), 0, 0, image.getWidth(), image.getHeight()); } finally { image.close(); } } finally { createOptions.close(); } // A large number of graphic operations are also supported: final int OperationAreaSize = 10; createOptions = new com.aspose.imaging.imageoptions.PngOptions(); createOptions.setBufferSizeHint(30); // Memory limit is 30 Mb createOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(workDir + "temporary.png")); try { image = com.aspose.imaging.Image.create(createOptions, ImageSize, ImageSize); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); graphics.beginUpdate(); graphics.clear(com.aspose.imaging.Color.getLightSkyBlue()); int x, y; for (int column = 0; column * OperationAreaSize < ImageSize; column++) { for (int row = 0; row * OperationAreaSize < ImageSize; row++) { x = column * OperationAreaSize; y = row * OperationAreaSize; boolean reversed = (column + row) % 2 != 0; if (reversed) { graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed()), x + OperationAreaSize - 2, y, x, y + OperationAreaSize); } else { graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed()), x, y, x + OperationAreaSize - 2, y + OperationAreaSize); } } } // About 40k operations will be applied here, while they do not take up too much memory // (since they are already unloaded into the external file, and will be loaded from there one at a time) graphics.endUpdate(); } finally { image.close(); } } finally { createOptions.close(); }
public void clear(Color color)
Clears the graphics surface using the specified color.
color
- The color to clear the graphics surface by.This examples make use of GraphicsPath and Graphics class to create and manipulate Figures on an Image surface. Example creates a new Image (of type Tiff) and draw paths with the help of GraphicsPath class. At the end DrawPath method exposed by Graphics class is called to render the paths on surface.
// Create an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.tif", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of TiffOptions and set its various properties com.aspose.imaging.imageoptions.TiffOptions tiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set the source for the instance of ImageOptions tiffOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(tiffOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Create an instance of GraphicsPath class com.aspose.imaging.GraphicsPath graphicspath = new com.aspose.imaging.GraphicsPath(); // Create an instance of Figure class com.aspose.imaging.Figure figure = new com.aspose.imaging.Figure(); // Add Shapes to Figure object figure.addShape(new com.aspose.imaging.shapes.RectangleShape(new com.aspose.imaging.RectangleF(10, 10, 300, 300))); figure.addShape(new com.aspose.imaging.shapes.EllipseShape(new com.aspose.imaging.RectangleF(50, 50, 300, 300))); figure.addShape( new com.aspose.imaging.shapes.PieShape(new com.aspose.imaging.RectangleF( new com.aspose.imaging.PointF(250, 250), new com.aspose.imaging.SizeF(200, 200)), 0, 45)); // Add Figure object to GraphicsPath graphicspath.addFigure(figure); // Draw path with Pen object of color Black graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), graphicspath); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawLine(Pen pen, Point point1, Point point2)
Draws a line connecting two Point
structures.
pen
- Pen
that determines the color, width, and style of the line.point1
- Point
structure that represents the first point to connect.point2
- Point
structure that represents the second point to connect.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawLine(Pen pen, PointF point1, PointF point2)
Draws a line connecting two PointF
structures.
pen
- Pen
that determines the color, width, and style of the line.point1
- PointF
structure that represents the first point to connect.point2
- PointF
structure that represents the second point to connect.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawLine(Pen pen, int x1, int y1, int x2, int y2)
Draws a line connecting the two points specified by the coordinate pairs.
pen
- Pen
that determines the color, width, and style of the line.x1
- The x-coordinate of the first point.y1
- The y-coordinate of the first point.x2
- The x-coordinate of the second point.y2
- The y-coordinate of the second point.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawLine(Pen pen, float x1, float y1, float x2, float y2)
Draws a line connecting the two points specified by the coordinate pairs.
pen
- Pen
that determines the color, width, and style of the line.x1
- The x-coordinate of the first point.y1
- The y-coordinate of the first point.x2
- The x-coordinate of the second point.y2
- The y-coordinate of the second point.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawLines(Pen pen, Point[] points)
Draws a series of line segments that connect an array of Point
structures.
pen
- Pen
that determines the color, width, and style of the line segments.points
- Array of Point
structures that represent the points to connect.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.com.aspose.ms.System.ArgumentException
- The points
array contains less than 2 points.public void drawLines(Pen pen, PointF[] points)
Draws a series of line segments that connect an array of PointF
structures.
pen
- Pen
that determines the color, width, and style of the line segments.points
- Array of PointF
structures that represent the points to connect.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.com.aspose.ms.System.ArgumentException
- The points
array contains less than 2 points.public void fillRectangle(Brush brush, Rectangle rect)
Fills the interior of a rectangle specified by a Rectangle
structure.
brush
- Brush
that determines the characteristics of the fill.rect
- Rectangle
structure that represents the rectangle to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillRectangle(Brush brush, RectangleF rect)
Fills the interior of a rectangle specified by a RectangleF
structure.
brush
- Brush
that determines the characteristics of the fill.rect
- RectangleF
structure that represents the rectangle to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillRectangle(Brush brush, float x, float y, float width, float height)
Fills the interior of a rectangle specified by a pair of coordinates, a width and a height.
brush
- Brush
that determines the characteristics of the fill.x
- The x-coordinate of the upper-left corner of the rectangle to fill.y
- The y-coordinate of the upper-left corner of the rectangle to fill.width
- Width of the rectangle to fill.height
- Height of the rectangle to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillRectangle(Brush brush, int x, int y, int width, int height)
Fills the interior of a rectangle specified by a pair of coordinates, a width and a height.
brush
- Brush
that determines the characteristics of the fill.x
- The x-coordinate of the upper-left corner of the rectangle to fill.y
- The y-coordinate of the upper-left corner of the rectangle to fill.width
- Width of the rectangle to fill.height
- Height of the rectangle to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillRectangles(Brush brush, Rectangle[] rects)
Fills the interiors of a series of rectangles specified by Rectangle
structures.
brush
- Brush
that determines the characteristics of the fill.rects
- Array of Rectangle
structures that represent the rectangles to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null or rects
is null.public void fillRectangles(Brush brush, RectangleF[] rects)
Fills the interiors of a series of rectangles specified by RectangleF
structures.
brush
- Brush
that determines the characteristics of the fill.rects
- Array of Rectangle
structures that represent the rectangles to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null or rects
is null.public void drawRectangle(Pen pen, RectangleF rect)
Draws a rectangle specified by a RectangleF
structure.
pen
- A Pen
that determines the color, width, and style of the rectangle.rect
- A RectangleF
structure that represents the rectangle to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawRectangle(Pen pen, Rectangle rect)
Draws a rectangle specified by a Rectangle
structure.
pen
- A Pen
that determines the color, width, and style of the rectangle.rect
- A Rectangle
structure that represents the rectangle to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawRectangle(Pen pen, float x, float y, float width, float height)
Draws a rectangle specified by a coordinate pair, a width, and a height.
pen
- A Pen
that determines the color, width, and style of the rectangle.x
- The x-coordinate of the upper-left corner of the rectangle to draw.y
- The y-coordinate of the upper-left corner of the rectangle to draw.width
- The width of the rectangle to draw.height
- The height of the rectangle to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawRectangle(Pen pen, int x, int y, int width, int height)
Draws a rectangle specified by a coordinate pair, a width, and a height.
pen
- Pen
that determines the color, width, and style of the rectangle.x
- The x-coordinate of the upper-left corner of the rectangle to draw.y
- The y-coordinate of the upper-left corner of the rectangle to draw.width
- Width of the rectangle to draw.height
- Height of the rectangle to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawRectangles(Pen pen, RectangleF[] rects)
Draws a series of rectangles specified by RectangleF
structures.
pen
- Pen
that determines the color, width, and style of the outlines of the rectangles.rects
- Array of RectangleF
structures that represent the rectangles to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
rects
is null.public void drawRectangles(Pen pen, Rectangle[] rects)
Draws a series of rectangles specified by Rectangle
structures.
pen
- Pen
that determines the color, width, and style of the outlines of the rectangles.rects
- Array of Rectangle
structures that represent the rectangles to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
rects
is null.This example shows the creation and usage Pen objects. The example creates a new Image and draw Rectangles on Image surface.
// Create an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpOptions.setBitsPerPixel(24); // Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions // Second Boolean parameter determines if the file to be created IsTemporal or not bmpOptions.setSource(new com.aspose.imaging.sources.FileCreateSource("C:\\temp\\sample.bmp", false)); // Create an instance of Image at specified Path com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpOptions, 500, 500); try { // Create an instance of Graphics and initialize it with Image object com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear the Graphics sutface with White Color graphics.clear(com.aspose.imaging.Color.getWhite()); // Create an instance of Pen with color Red and width 5 com.aspose.imaging.Pen pen = new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 5); // Create an instance of HatchBrush and set its properties com.aspose.imaging.brushes.HatchBrush brush = new com.aspose.imaging.brushes.HatchBrush(); brush.setBackgroundColor(com.aspose.imaging.Color.getWheat()); brush.setForegroundColor(com.aspose.imaging.Color.getRed()); // Create an instance of Pen and initialize it with HatchBrush object and width com.aspose.imaging.Pen brushedpen = new com.aspose.imaging.Pen(brush, 5); // Draw Rectangles by specifying Pen object graphics.drawRectangles(pen, new com.aspose.imaging.Rectangle[] { new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(210, 210), new com.aspose.imaging.Size(100, 100)), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(110, 110), new com.aspose.imaging.Size(100, 100)), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(310, 310), new com.aspose.imaging.Size(100, 100)) }); // Draw Rectangles by specifying Pen object graphics.drawRectangles( brushedpen, new com.aspose.imaging.Rectangle[] { new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(310, 110), new com.aspose.imaging.Size(100, 100)), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(110, 310), new com.aspose.imaging.Size(100, 100)) }); // Save all changes. image.save(); } finally { image.dispose(); }
public void drawEllipse(Pen pen, RectangleF rect)
Draws an ellipse defined by a bounding RectangleF
.
pen
- Pen
that determines the color, width, and style of the ellipse.rect
- RectangleF
structure that defines the boundaries of the ellipse.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawEllipse(Pen pen, float x, float y, float width, float height)
Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.
pen
- Pen
that determines the color, width, and style of the ellipse.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.width
- Width of the bounding rectangle that defines the ellipse.height
- Height of the bounding rectangle that defines the ellipse.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawEllipse(Pen pen, Rectangle rect)
Draws an ellipse specified by a bounding Rectangle
structure.
pen
- Pen
that determines the color, width, and style of the ellipse.rect
- Rectangle
structure that defines the boundaries of the ellipse.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawEllipse(Pen pen, int x, int y, int width, int height)
Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.
pen
- Pen
that determines the color, width, and style of the ellipse.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.width
- Width of the bounding rectangle that defines the ellipse.height
- Height of the bounding rectangle that defines the ellipse.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawPolygon(Pen pen, PointF[] points)
Draws a polygon defined by an array of PointF
structures.
pen
- Pen
that determines the color, width, and style of the polygon.points
- Array of PointF
structures that represent the vertices of the polygon.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawPolygon(Pen pen, Point[] points)
Draws a polygon defined by an array of Point
structures.
pen
- Pen
that determines the color, width, and style of the polygon.points
- Array of Point
structures that represent the vertices of the polygon.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawImage(Image sourceImage, PointF point)
Draws the specified Image
, using its original physical size, at the specified location.
sourceImage
- The image to draw with.point
- PointF
structure that represents the upper-left corner of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, float x, float y)
Draws the specified Image
, using its original physical size, at the specified location.
sourceImage
- The image to draw with.x
- The x-coordinate of the upper-left corner of the drawn image.y
- The y-coordinate of the upper-left corner of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, RectangleF rect)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rect
- RectangleF
structure that specifies the location and size of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, Rectangle rectDestination, int graphicsUnit)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectDestination
- The destination rectangle.graphicsUnit
- The graphics unit.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, RectangleF rectDestination, int graphicsUnit)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectDestination
- The destination rectangle.graphicsUnit
- The graphics unit.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, Rectangle rectDestination, int graphicsUnit, ImageAttributes imageAttributes)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectDestination
- The destination rectangle.graphicsUnit
- The graphics unit.imageAttributes
- The image attributes.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, RectangleF rectDestination, int graphicsUnit, ImageAttributes imageAttributes)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectDestination
- The destination rectangle to draw in.graphicsUnit
- The graphics unit.imageAttributes
- The image attributes.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, Rectangle rectSource, Rectangle rectDestination, int graphicsUnit)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectSource
- The rect source.rectDestination
- The rect destination.graphicsUnit
- The graphics unit.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, RectangleF rectSource, RectangleF rectDestination, int graphicsUnit)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectSource
- The rect source.rectDestination
- The rect destination.graphicsUnit
- The graphics unit.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, Rectangle rectSource, Rectangle rectDestination, int graphicsUnit, ImageAttributes imageAttributes)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectSource
- The rect source.rectDestination
- The rect destination.graphicsUnit
- The graphics unit.imageAttributes
- The image attributes.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, RectangleF rectSource, RectangleF rectDestination, int graphicsUnit, ImageAttributes imageAttributes)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rectSource
- The source rectangle.rectDestination
- The destination rectangle.graphicsUnit
- The graphics unit to use.imageAttributes
- The image attributes to use.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image image, Point[] destPoints)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.public void drawImage(Image image, Point[] destPoints, Rectangle srcRect)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.srcRect
- The source rectangle.public void drawImage(Image image, Point[] destPoints, Rectangle srcRect, int srcUnit)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.srcRect
- The source rectangle.srcUnit
- The units of measure.public void drawImage(Image image, Point[] destPoints, Rectangle srcRect, int srcUnit, ImageAttributes imageAttributes)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.srcRect
- The source rectangle.srcUnit
- The units of measure.imageAttributes
- The image attributes.public void drawImage(Image image, PointF[] destPoints)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.com.aspose.ms.System.ArgumentNullException
- imagepublic void drawImage(Image image, PointF[] destPoints, RectangleF srcRect)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.srcRect
- The source rectangle.public void drawImage(Image image, PointF[] destPoints, RectangleF srcRect, int srcUnit)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.srcRect
- The source rectangle.srcUnit
- The units of measure.public void drawImage(Image image, PointF[] destPoints, RectangleF srcRect, int srcUnit, ImageAttributes imageAttributes)
Draws the specified portion of the specified image
at the specified location and with the specified size.
image
- The image to draw.destPoints
- Array of three PointF structures that define a parallelogram.srcRect
- The source rectangle.srcUnit
- The units of measure.imageAttributes
- The image attributes.public void drawImage(Image sourceImage, float x, float y, float width, float height)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.x
- The x-coordinate of the upper-left corner of the drawn image.y
- The y-coordinate of the upper-left corner of the drawn image.width
- Width of the drawn image.height
- Height of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, Point point)
Draws the specified Image
, using its original physical size, at the specified location.
sourceImage
- The image to draw with.point
- Point
structure that represents the location of the upper-left corner of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, int x, int y)
Draws the specified image, using its original physical size, at the location specified by a coordinate pair.
sourceImage
- The image to draw with.x
- The x-coordinate of the upper-left corner of the drawn image.y
- The y-coordinate of the upper-left corner of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, Rectangle rect)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.rect
- Rectangle
structure that specifies the location and size of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImage(Image sourceImage, int x, int y, int width, int height)
Draws the specified Image
at the specified location and with the specified size.
sourceImage
- The image to draw with.x
- The x-coordinate of the upper-left corner of the drawn image.y
- The y-coordinate of the upper-left corner of the drawn image.width
- Width of the drawn image.height
- Height of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImageUnscaled(Image sourceImage, Point point)
Draws a specified image using its original physical size at a specified location.
sourceImage
- The image to draw with.point
- Point
structure that specifies the upper-left corner of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImageUnscaled(Image sourceImage, int x, int y)
Draws the specified image using its original physical size at the location specified by a coordinate pair.
sourceImage
- The image to draw with.x
- The x-coordinate of the upper-left corner of the drawn image.y
- The y-coordinate of the upper-left corner of the drawn image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImageUnscaled(Image sourceImage, Rectangle rect)
Draws a specified image using its original physical size at a specified location.
sourceImage
- The image to draw with.rect
- Rectangle
that specifies the upper-left corner of the drawn image. The X and Y properties of the rectangle specify the upper-left corner. The Width and Height properties are ignored.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImageUnscaled(Image sourceImage, int x, int y, int width, int height)
Draws a specified image using its original physical size at a specified location.
sourceImage
- The image to draw with.x
- The x-coordinate of the upper-left corner of the drawn image.y
- The y-coordinate of the upper-left corner of the drawn image.width
- The parameter is not used.height
- The parameter is not used.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawImageUnscaledAndClipped(Image sourceImage, Rectangle rect)
Draws the specified image without scaling and clips it, if necessary, to fit in the specified rectangle.
sourceImage
- The image to draw with.rect
- The Rectangle
in which to draw the image.com.aspose.ms.System.ArgumentNullException
- sourceImage
is null.public void drawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.
pen
- Pen
that determines the color, width, and style of the arc.x
- The x-coordinate of the upper-left corner of the rectangle that defines the ellipse.y
- The y-coordinate of the upper-left corner of the rectangle that defines the ellipse.width
- Width of the rectangle that defines the ellipse.height
- Height of the rectangle that defines the ellipse.startAngle
- Angle in degrees measured clockwise from the x-axis to the starting point of the arc.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to ending point of the arc.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle)
Draws an arc representing a portion of an ellipse specified by a RectangleF
structure.
pen
- Pen
that determines the color, width, and style of the arc.rect
- RectangleF
structure that defines the boundaries of the ellipse.startAngle
- Angle in degrees measured clockwise from the x-axis to the starting point of the arc.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to ending point of the arc.com.aspose.ms.System.ArgumentNullException
- pen
is nullpublic void drawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.
pen
- Pen
that determines the color, width, and style of the arc.x
- The x-coordinate of the upper-left corner of the rectangle that defines the ellipse.y
- The y-coordinate of the upper-left corner of the rectangle that defines the ellipse.width
- Width of the rectangle that defines the ellipse.height
- Height of the rectangle that defines the ellipse.startAngle
- Angle in degrees measured clockwise from the x-axis to the starting point of the arc.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to ending point of the arc.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
Draws an arc representing a portion of an ellipse specified by a Rectangle
structure.
pen
- Pen
that determines the color, width, and style of the arc.rect
- RectangleF
structure that defines the boundaries of the ellipse.startAngle
- Angle in degrees measured clockwise from the x-axis to the starting point of the arc.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to ending point of the arc.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawPie(Pen pen, RectangleF rect, float startAngle, float sweepAngle)
Draws a pie shape defined by an ellipse specified by a RectangleF
structure and two radial lines.
pen
- Pen
that determines the color, width, and style of the pie shape.rect
- RectangleF
structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.startAngle
- Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.sweepAngle
- Angle measured in degrees clockwise from the startAngle
parameter to the second side of the pie shape.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
pen
- Pen
that determines the color, width, and style of the pie shape.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.width
- Width of the bounding rectangle that defines the ellipse from which the pie shape comes.height
- Height of the bounding rectangle that defines the ellipse from which the pie shape comes.startAngle
- Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.sweepAngle
- Angle measured in degrees clockwise from the startAngle
parameter to the second side of the pie shape.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
Draws a pie shape defined by an ellipse specified by a Rectangle
structure and two radial lines.
pen
- Pen
that determines the color, width, and style of the pie shape.rect
- Rectangle
structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.startAngle
- Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.sweepAngle
- Angle measured in degrees clockwise from the startAngle
parameter to the second side of the pie shape.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawPie(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
pen
- Pen
that determines the color, width, and style of the pie shape.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.width
- Width of the bounding rectangle that defines the ellipse from which the pie shape comes.height
- Height of the bounding rectangle that defines the ellipse from which the pie shape comes.startAngle
- Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.sweepAngle
- Angle measured in degrees clockwise from the startAngle
parameter to the second side of the pie shape.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawCurve(Pen pen, PointF[] points)
Draws a cardinal spline through a specified array of PointF
structures. This method uses a default tension of 0.5.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of PointF
structures that define the spline.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawCurve(Pen pen, PointF[] points, float tension)
Draws a cardinal spline through a specified array of PointF
structures using a specified tension.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of PointF
structures that represent the points that define the curve.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments)
Draws a cardinal spline through a specified array of PointF
structures. The drawing begins offset from the beginning of the array.
This method uses a default tension of 0.5.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of PointF
structures that define the spline.offset
- Offset from the first element in the array of the points
parameter to the starting point in the curve.numberOfSegments
- Number of segments after the starting point to include in the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension)
Draws a cardinal spline through a specified array of PointF
structures using a specified tension. The drawing begins offset from the beginning of the array.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of PointF
structures that define the spline.offset
- Offset from the first element in the array of the points
parameter to the starting point in the curve.numberOfSegments
- Number of segments after the starting point to include in the curve.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawCurve(Pen pen, Point[] points)
Draws a cardinal spline through a specified array of Point
structures.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of Point
structures that define the spline.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawCurve(Pen pen, Point[] points, float tension)
Draws a cardinal spline through a specified array of Point
structures using a specified tension.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of Point
structures that define the spline.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, float tension)
Draws a cardinal spline through a specified array of Point
structures using a specified tension.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of Point
structures that define the spline.offset
- Offset from the first element in the array of the points
parameter to the starting point in the curve.numberOfSegments
- Number of segments after the starting point to include in the curve.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawClosedCurve(Pen pen, PointF[] points)
Draws a closed cardinal spline defined by an array of PointF
structures. This method uses a default tension of 0.5 and FillMode.Alternate
fill mode.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of PointF
structures that define the spline.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawClosedCurve(Pen pen, PointF[] points, float tension)
Draws a closed cardinal spline defined by an array of PointF
structures using a specified tension. This method uses a default FillMode.Alternate
fill mode.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of PointF
structures that define the spline.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawClosedCurve(Pen pen, Point[] points)
Draws a closed cardinal spline defined by an array of Point
structures. This method uses a default tension of 0.5 and FillMode.Alternate
fill mode.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of Point
structures that define the spline.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawClosedCurve(Pen pen, Point[] points, float tension)
Draws a closed cardinal spline defined by an array of Point
structures using a specified tension. This method uses a default FillMode.Alternate
fill mode.
pen
- Pen
that determines the color, width, and height of the curve.points
- Array of Point
structures that define the spline.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawBezier(Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.
pen
- Pen
that determines the color, width, and style of the curve.x1
- The x-coordinate of the starting point of the curve.y1
- The y-coordinate of the starting point of the curve.x2
- The x-coordinate of the first control point of the curve.y2
- The y-coordinate of the first control point of the curve.x3
- The x-coordinate of the second control point of the curve.y3
- The y-coordinate of the second control point of the curve.x4
- The x-coordinate of the ending point of the curve.y4
- The y-coordinate of the ending point of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawBezier(Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
Draws a Bézier spline defined by four PointF
structures.
pen
- Pen
that determines the color, width, and style of the curve.pt1
- PointF
structure that represents the starting point of the curve.pt2
- PointF
structure that represents the first control point for the curve.pt3
- PointF
structure that represents the second control point for the curve.pt4
- PointF
structure that represents the ending point of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.public void drawBezier(Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
Draws a Bézier spline defined by four Point
structures.
pen
- Pen
structure that determines the color, width, and style of the curve.pt1
- Point
structure that represents the starting point of the curve.pt2
- Point
structure that represents the first control point for the curve.pt3
- Point
structure that represents the second control point for the curve.pt4
- Point
structure that represents the ending point of the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.This example uses Graphics class to create primitive shapes on the Image surface. To demonstrate the operation, the example creates a new Image in PNG format and draw primitive shapes on Image surface using Draw methods exposed by Graphics class
// Creates an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.png", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of PngOptions and set its various properties com.aspose.imaging.imageoptions.PngOptions pngOptions = new com.aspose.imaging.imageoptions.PngOptions(); // Set the Source for PngOptions pngOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(pngOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Draw an Arc by specifying the Pen object having Black com.aspose.imaging.Color, // a Rectangle surrounding the Arc, Start Angle and Sweep Angle graphics.drawArc( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), new com.aspose.imaging.Rectangle(200, 200, 100, 200), 0, 300); // Draw a Bezier by specifying the Pen object having Blue com.aspose.imaging.Color and co-ordinate Points. graphics.drawBezier( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Point(250, 100), new com.aspose.imaging.Point(300, 30), new com.aspose.imaging.Point(450, 100), new com.aspose.imaging.Point(235, 25)); // Draw a Curve by specifying the Pen object having Green com.aspose.imaging.Color and an array of Points graphics.drawCurve( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(100, 200), new com.aspose.imaging.Point(100, 350), new com.aspose.imaging.Point(200, 450) }); // Draw an Ellipse using the Pen object and a surrounding Rectangle graphics.drawEllipse( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getYellow(), 2), new com.aspose.imaging.Rectangle(300, 300, 100, 100)); // Draw a Line graphics.drawLine( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getViolet(), 2), new com.aspose.imaging.Point(100, 100), new com.aspose.imaging.Point(200, 200)); // Draw a Pie segment graphics.drawPie( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getSilver(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(200, 20), new com.aspose.imaging.Size(200, 200)), 0, 45); // Draw a Polygon by specifying the Pen object having Red com.aspose.imaging.Color and an array of Points graphics.drawPolygon( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2), new com.aspose.imaging.Point[] { new com.aspose.imaging.Point(20, 100), new com.aspose.imaging.Point(20, 200), new com.aspose.imaging.Point(220, 20) }); // Draw a Rectangle graphics.drawRectangle( new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 2), new com.aspose.imaging.Rectangle(new com.aspose.imaging.Point(250, 250), new com.aspose.imaging.Size(100, 100))); // Create a SolidBrush object and set its various properties com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(); brush.setColor(com.aspose.imaging.Color.getPurple()); brush.setOpacity(100f); // Draw a String using the SolidBrush object and Font, at specific Point graphics.drawString( "This image is created by Aspose.Imaging API", new com.aspose.imaging.Font("Times New Roman", 16), brush, new com.aspose.imaging.PointF(50, 400)); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void drawBeziers(Pen pen, Point[] points)
Draws a series of Bézier splines from an array of Point
structures.
pen
- Pen
that determines the color, width, and style of the curve.points
- Array of Point
structures that represent the points that determine the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawBeziers(Pen pen, PointF[] points)
Draws a series of Bézier splines from an array of PointF
structures.
pen
- Pen
that determines the color, width, and style of the curve.points
- Array of PointF
structures that represent the points that determine the curve.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
points
is null.public void drawString(String s, Font font, Brush brush, float x, float y)
Draws the specified text string at the specified location with the specified com.aspose.imaging.Brush
and com.aspose.imaging.Font
objects.
s
- String to draw.font
- com.aspose.imaging.Font
that defines the text format of the string.brush
- com.aspose.imaging.Brush
that determines the color and texture of the drawn text.x
- The x-coordinate of the upper-left corner of the drawn text.y
- The y-coordinate of the upper-left corner of the drawn text.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
s
is null.public void drawString(String s, Font font, Brush brush, PointF point)
Draws the specified text string at the specified location with the specified com.aspose.imaging.Brush
and com.aspose.imaging.Font
objects.
s
- String to draw.font
- com.aspose.imaging.Font
that defines the text format of the string.brush
- com.aspose.imaging.Brush
that determines the color and texture of the drawn text.point
- com.aspose.imaging.PointF
structure that specifies the upper-left corner of the drawn text.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
s
is null.This example demonstrates the use of Font and SolidBrush class to draw strings on Image surface. The example creates a new Image and draw shapes using Figures and GraphicsPath
//Creates an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpOptions.setBitsPerPixel(24); //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions //Second Boolean parameter determines if the file to be created IsTemporal or not bmpOptions.setSource(new com.aspose.imaging.sources.FileCreateSource("C:\\temp\\sample.bmp", false)); //Creates an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpOptions, 500, 500); try { //Creates and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); //Clears Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); //Creates an instance of Font com.aspose.imaging.Font font = new com.aspose.imaging.Font("Times New Roman", 16); //Create an instance of SolidBrush having Red Color com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed()); //Draw a String graphics.drawString("Created by Aspose.Imaging for Java", font, brush, new com.aspose.imaging.PointF(100, 100)); // save all changes image.save(); } finally { image.dispose(); }
public void drawString(String s, Font font, Brush brush, float x, float y, StringFormat format)
Draws the specified text string at the specified location with the specified com.aspose.imaging.Brush
and com.aspose.imaging.Font
objects using the formatting attributes of the specified com.aspose.imaging.stringFormat
.
s
- String to draw.font
- com.aspose.imaging.Font
that defines the text format of the string.brush
- com.aspose.imaging.Brush
that determines the color and texture of the drawn text.x
- The x-coordinate of the upper-left corner of the drawn text.y
- The y-coordinate of the upper-left corner of the drawn text.format
- com.aspose.imaging.StringFormat
that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
s
is null.public void drawString(String s, Font font, Brush brush, PointF point, StringFormat format)
Draws the specified text string at the specified location with the specified com.aspose.imaging.Brush
and com.aspose.imaging.Font
objects using the formatting attributes of the specified com.aspose.imaging.stringFormat
.
s
- String to draw.font
- com.aspose.imaging.Font
that defines the text format of the string.brush
- com.aspose.imaging.Brush
that determines the color and texture of the drawn text.point
- com.aspose.imaging.PointF
structure that specifies the upper-left corner of the drawn text.format
- com.aspose.imaging.StringFormat
that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
s
is null.public void drawString(String s, Font font, Brush brush, RectangleF layoutRectangle)
Draws the specified text string in the specified rectangle with the specified com.aspose.imaging.Brush
and com.aspose.imaging.Font
objects.
s
- String to draw.font
- com.aspose.imaging.Font
that defines the text format of the string.brush
- com.aspose.imaging.Brush
that determines the color and texture of the drawn text.layoutRectangle
- com.aspose.imaging.RectangleF
structure that specifies the location of the drawn text.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
s
is null.public void drawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
Draws the specified text string in the specified rectangle with the specified com.aspose.imaging.Brush
and com.aspose.imaging.Font
objects using the formatting attributes of the specified com.aspose.imaging.stringFormat
.
s
- String to draw.font
- com.aspose.imaging.Font
that defines the text format of the string.brush
- com.aspose.imaging.Brush
that determines the color and texture of the drawn text.layoutRectangle
- com.aspose.imaging.RectangleF
structure that specifies the location of the drawn text.format
- com.aspose.imaging.StringFormat
that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
s
is null.
-or-
brush
is null.public void fillEllipse(Brush brush, RectangleF rect)
Fills the interior of an ellipse defined by a bounding rectangle specified by a com.aspose.imaging.RectangleF
structure.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.rect
- com.aspose.imaging.RectangleF
structure that represents the bounding rectangle that defines the ellipse.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillEllipse(Brush brush, float x, float y, float width, float height)
Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates, a width, and a height.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.width
- Width of the bounding rectangle that defines the ellipse.height
- Height of the bounding rectangle that defines the ellipse.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillEllipse(Brush brush, Rectangle rect)
Fills the interior of an ellipse defined by a bounding rectangle specified by a com.aspose.imaging.Rectangle
structure.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.rect
- com.aspose.imaging.Rectangle
structure that represents the bounding rectangle that defines the ellipse.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillEllipse(Brush brush, int x, int y, int width, int height)
Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates, a width, and a height.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.width
- Width of the bounding rectangle that defines the ellipse.height
- Height of the bounding rectangle that defines the ellipse.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a com.aspose.imaging.RectangleF
structure and two radial lines.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.rect
- com.aspose.imaging.Rectangle
structure that represents the bounding rectangle that defines the ellipse from which the pie section comes.startAngle
- Angle in degrees measured clockwise from the x-axis to the first side of the pie section.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to the second side of the pie section.com.aspose.ms.System.ArgumentNullException
- brush
is null.The following example shows how to compose an animated GIF image from individual GIF blocks.
String dir = "c:\\temp\\"; // Create a GIF image 100 x 100 px. // The first block is fully black by default. com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock firstBlock = new com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock(100, 100); com.aspose.imaging.fileformats.gif.GifImage gifImage = new com.aspose.imaging.fileformats.gif.GifImage(firstBlock); try { // The first circle is red com.aspose.imaging.brushes.SolidBrush brush1 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed()); // The second circle is black com.aspose.imaging.brushes.SolidBrush brush2 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getBlack()); // Gradually increase the angle of the red arc shape. for (int angle = 10; angle <= 360; angle += 10) { com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock block = new com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock(100, 100); com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(block); gr.fillPie(brush1, block.getBounds(), 0, angle); gifImage.addBlock(block); } // Gradually increase the angle of the black arc and wipe out the red arc. for (int angle = 10; angle <= 360; angle += 10) { com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock block = new com.aspose.imaging.fileformats.gif.blocks.GifFrameBlock(100, 100); com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(block); gr.fillPie(brush2, block.getBounds(), 0, angle); gr.fillPie(brush1, block.getBounds(), angle, 360 - angle); gifImage.addBlock(block); } gifImage.save(dir + "animated_radar.gif"); } finally { firstBlock.dispose(); gifImage.dispose(); }
public void fillPie(Brush brush, RectangleF rect, float startAngle, float sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a com.aspose.imaging.RectangleF
structure and two radial lines.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.rect
- com.aspose.imaging.RectangleF
structure that represents the bounding rectangle that defines the ellipse from which the pie section comes.startAngle
- Angle in degrees measured clockwise from the x-axis to the first side of the pie section.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to the second side of the pie section.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates, a width, a height, and two radial lines.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.width
- Width of the bounding rectangle that defines the ellipse from which the pie section comes.height
- Height of the bounding rectangle that defines the ellipse from which the pie section comes.startAngle
- Angle in degrees measured clockwise from the x-axis to the first side of the pie section.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to the second side of the pie section.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillPie(Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates, a width, a height, and two radial lines.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.x
- The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.y
- The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.width
- Width of the bounding rectangle that defines the ellipse from which the pie section comes.height
- Height of the bounding rectangle that defines the ellipse from which the pie section comes.startAngle
- Angle in degrees measured clockwise from the x-axis to the first side of the pie section.sweepAngle
- Angle in degrees measured clockwise from the startAngle
parameter to the second side of the pie section.com.aspose.ms.System.ArgumentNullException
- brush
is null.public void fillPolygon(Brush brush, PointF[] points)
Fills the interior of a polygon defined by an array of points specified by com.aspose.imaging.PointF
structures and FillMode.Alternate
.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.PointF
structures that represent the vertices of the polygon to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillPolygon(Brush brush, PointF[] points, int fillMode)
Fills the interior of a polygon defined by an array of points specified by com.aspose.imaging.PointF
structures using the specified fill mode.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.PointF
structures that represent the vertices of the polygon to fill.fillMode
- Member of the com.aspose.imaging.FillMode
enumeration that determines the style of the fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillPolygon(Brush brush, Point[] points)
Fills the interior of a polygon defined by an array of points specified by com.aspose.imaging.Point
structures and FillMode.Alternate
.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.Point
structures that represent the vertices of the polygon to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillPolygon(Brush brush, Point[] points, int fillMode)
Fills the interior of a polygon defined by an array of points specified by com.aspose.imaging.Point
structures using the specified fill mode.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.Point
structures that represent the vertices of the polygon to fill.fillMode
- Member of the com.aspose.imaging.FillMode
enumeration that determines the style of the fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillClosedCurve(Brush brush, PointF[] points)
Fills the interior of a closed cardinal spline curve defined by an array of com.aspose.imaging.PointF
structures. This method uses a default tension of 0.5 and FillMode.Alternate
fill mode.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.PointF
structures that define the spline.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillClosedCurve(Brush brush, PointF[] points, int fillmode)
Fills the interior of a closed cardinal spline curve defined by an array of com.aspose.imaging.PointF
structures using the specified fill mode. This method uses a default tension of 0.5.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.PointF
structures that define the spline.fillmode
- Member of the com.aspose.imaging.FillMode
enumeration that determines how the curve is filled.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillClosedCurve(Brush brush, PointF[] points, int fillmode, float tension)
Fills the interior of a closed cardinal spline curve defined by an array of com.aspose.imaging.PointF
structures using the specified fill mode and tension.
brush
- A com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.PointF
structures that define the spline.fillmode
- Member of the com.aspose.imaging.FillMode
enumeration that determines how the curve is filled.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillClosedCurve(Brush brush, Point[] points)
Fills the interior of a closed cardinal spline curve defined by an array of com.aspose.imaging.Point
structures. This method uses a default tension of 0.5 and FillMode.Alternate
fill mode.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.Point
structures that define the spline.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillClosedCurve(Brush brush, Point[] points, int fillmode)
Fills the interior of a closed cardinal spline curve defined by an array of com.aspose.imaging.Point
structures using the specified fill mode. This method uses a default tension of 0.5.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.Point
structures that define the spline.fillmode
- Member of the com.aspose.imaging.FillMode
enumeration that determines how the curve is filled.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void fillClosedCurve(Brush brush, Point[] points, int fillmode, float tension)
Fills the interior of a closed cardinal spline curve defined by an array of com.aspose.imaging.Point
structures using the specified fill mode and tension.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.points
- Array of com.aspose.imaging.Point
structures that define the spline.fillmode
- Member of the com.aspose.imaging.FillMode
enumeration that determines how the curve is filled.tension
- Value greater than or equal to 0.0F that specifies the tension of the curve.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
points
is null.public void drawPath(Pen pen, GraphicsPath path)
Draws a com.aspose.imaging.graphicsPath
.
pen
- com.aspose.imaging.Pen
that determines the color, width, and style of the path.path
- com.aspose.imaging.GraphicsPath
to draw.com.aspose.ms.System.ArgumentNullException
- pen
is null.
-or-
path
is null.This examples make use of GraphicsPath and Graphics class to create and manipulate Figures on an Image surface. Example creates a new Image (of type Tiff) and draw paths with the help of GraphicsPath class. At the end DrawPath method exposed by Graphics class is called to render the paths on surface.
// Create an instance of FileStream com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.tif", com.aspose.imaging.system.io.FileMode.Create); try { // Create an instance of TiffOptions and set its various properties com.aspose.imaging.imageoptions.TiffOptions tiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set the source for the instance of ImageOptions tiffOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream)); // Create an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(tiffOptions, 500, 500); try { // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); // Clear Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); // Create an instance of GraphicsPath class com.aspose.imaging.GraphicsPath graphicspath = new com.aspose.imaging.GraphicsPath(); // Create an instance of Figure class com.aspose.imaging.Figure figure = new com.aspose.imaging.Figure(); // Add Shapes to Figure object figure.addShape(new com.aspose.imaging.shapes.RectangleShape(new com.aspose.imaging.RectangleF(10, 10, 300, 300))); figure.addShape(new com.aspose.imaging.shapes.EllipseShape(new com.aspose.imaging.RectangleF(50, 50, 300, 300))); figure.addShape( new com.aspose.imaging.shapes.PieShape(new com.aspose.imaging.RectangleF( new com.aspose.imaging.PointF(250, 250), new com.aspose.imaging.SizeF(200, 200)), 0, 45)); // Add Figure object to GraphicsPath graphicspath.addFigure(figure); // Draw path with Pen object of color Black graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), graphicspath); // Save all changes. image.save(); } finally { image.dispose(); } } finally { stream.dispose(); }
public void fillPath(Brush brush, GraphicsPath path)
Fills the interior of a com.aspose.imaging.graphicsPath
.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.path
- com.aspose.imaging.GraphicsPath
that represents the path to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
path
is null.public void fillRegion(Brush brush, Region region)
Fills the interior of a com.aspose.imaging.region
.
brush
- com.aspose.imaging.Brush
that determines the characteristics of the fill.region
- com.aspose.imaging.Region
that represents the area to fill.com.aspose.ms.System.ArgumentNullException
- brush
is null.
-or-
region
is null.