public final class LinearGradientBrush extends LinearGradientBrushBase
Encapsulates a Aspose.Imaging.Brush with a linear gradient. This class cannot be inherited.
| Constructor and Description |
|---|
LinearGradientBrush()
Initializes a new instance of the
LinearGradientBrush class with default parameters. |
LinearGradientBrush(PointF point1,
PointF point2,
Color color1,
Color color2)
Initializes a new instance of the
LinearGradientBrush class. |
LinearGradientBrush(Point point1,
Point point2,
Color color1,
Color color2)
Initializes a new instance of the
LinearGradientBrush class. |
LinearGradientBrush(Rectangle rect,
Color color1,
Color color2,
float angle)
Initializes a new instance of the
LinearGradientBrush class. |
LinearGradientBrush(Rectangle rect,
Color color1,
Color color2,
float angle,
boolean isAngleScalable)
Initializes a new instance of the
LinearGradientBrush class. |
LinearGradientBrush(RectangleF rect,
Color color1,
Color color2,
float angle)
Initializes a new instance of the
LinearGradientBrush class. |
LinearGradientBrush(RectangleF rect,
Color color1,
Color color2,
float angle,
boolean isAngleScalable)
Initializes a new instance of the
LinearGradientBrush class. |
| Modifier and Type | Method and Description |
|---|---|
Blend |
getBlend()
Gets a
Aspose.Imaging.Blend that specifies positions and factors that define a custom falloff for the gradient. |
Color |
getEndColor()
Gets the ending gradient color.
|
ColorBlend |
getInterpolationColors()
Deprecated.
|
Color[] |
getLinearColors()
Deprecated.
|
Color |
getStartColor()
Gets the starting gradient color.
|
void |
setBlend(Blend value)
Sets a
Aspose.Imaging.Blend that specifies positions and factors that define a custom falloff for the gradient. |
void |
setBlendTriangularShape(float focus)
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
|
void |
setBlendTriangularShape(float focus,
float scale)
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
|
void |
setEndColor(Color value)
Sets the ending gradient color.
|
void |
setInterpolationColors(ColorBlend value)
Deprecated.
|
void |
setLinearColors(Color[] value)
Deprecated.
|
void |
setSigmaBellShape(float focus)
Creates a gradient falloff based on a bell-shaped curve.
|
void |
setSigmaBellShape(float focus,
float scale)
Creates a gradient falloff based on a bell-shaped curve.
|
void |
setStartColor(Color value)
Sets the starting gradient color.
|
getAngle, getGammaCorrection, getRectangle, isAngleScalable, setAngle, setAngleScalable, setGammaCorrection, setRectanglegetTransform, getWrapMode, isTransformChanged, multiplyTransform, multiplyTransform, resetTransform, rotateTransform, rotateTransform, scaleTransform, scaleTransform, setTransform, setWrapMode, translateTransform, translateTransformdeepClone, equals, getOpacity, hashCode, setOpacityclose, dispose, getDisposedpublic LinearGradientBrush(RectangleF rect, Color color1, Color color2, float angle, boolean isAngleScalable)
Initializes a new instance of the LinearGradientBrush class.
rect - The rectangle.color1 - The color1.color2 - The color2.angle - The angle.isAngleScalable - if set to true [is angle scalable].public LinearGradientBrush(Rectangle rect, Color color1, Color color2, float angle, boolean isAngleScalable)
Initializes a new instance of the LinearGradientBrush class.
rect - The rectangle.color1 - The color1.color2 - The color2.angle - The angle.isAngleScalable - if set to true [is angle scalable].public LinearGradientBrush(RectangleF rect, Color color1, Color color2, float angle)
Initializes a new instance of the LinearGradientBrush class.
rect - The rectangle.color1 - The color1.color2 - The color2.angle - The angle.public LinearGradientBrush(Rectangle rect, Color color1, Color color2, float angle)
Initializes a new instance of the LinearGradientBrush class.
rect - The rectangle.color1 - The color1.color2 - The color2.angle - The angle.public LinearGradientBrush(PointF point1, PointF point2, Color color1, Color color2)
Initializes a new instance of the LinearGradientBrush class.
point1 - The point1.point2 - The point2.color1 - The color1.color2 - The color2.public LinearGradientBrush(Point point1, Point point2, Color color1, Color color2)
Initializes a new instance of the LinearGradientBrush class.
point1 - The point1.point2 - The point2.color1 - The color1.color2 - The color2.The following example shows how to create a grayscale copy of an existing frame and add it to a TIFF image.
String dir = "c:\\temp\\";
com.aspose.imaging.imageoptions.TiffOptions createTiffOptions
= new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
// Create a permanent, not temporary file source.
createTiffOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(dir + "multipage.tif", false));
createTiffOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb);
createTiffOptions.setBitsPerSample(new int[]{8, 8, 8});
com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = (com.aspose.imaging.fileformats.tiff.TiffImage) com.aspose.imaging.Image.create(createTiffOptions, 100, 100);
try {
// The linear gradient from the left-top to the right-bottom corner of the image.
com.aspose.imaging.brushes.LinearGradientBrush brush =
new com.aspose.imaging.brushes.LinearGradientBrush(
new com.aspose.imaging.Point(0, 0),
new com.aspose.imaging.Point(tiffImage.getWidth(), tiffImage.getHeight()),
com.aspose.imaging.Color.getRed(),
com.aspose.imaging.Color.getGreen());
// Fill the active frame with a linear gradient brush.
com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(tiffImage.getActiveFrame());
gr.fillRectangle(brush, tiffImage.getBounds());
// Grayscale options
com.aspose.imaging.imageoptions.TiffOptions createTiffFrameOptions
= new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
createTiffFrameOptions.setSource(new com.aspose.imaging.sources.StreamSource(new java.io.ByteArrayInputStream(new byte[0])));
createTiffFrameOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.MinIsBlack);
createTiffFrameOptions.setBitsPerSample(new int[]{8});
// Create a grayscale copy of the active frame.
// The pixel data is preserved but converted to the desired format.
com.aspose.imaging.fileformats.tiff.TiffFrame grayscaleFrame
= com.aspose.imaging.fileformats.tiff.TiffFrame.createFrameFrom(tiffImage.getActiveFrame(), createTiffFrameOptions);
// Add the newly created frame to the TIFF image.
tiffImage.addFrame(grayscaleFrame);
tiffImage.save();
} finally {
tiffImage.dispose();
}
public LinearGradientBrush()
Initializes a new instance of the LinearGradientBrush class with default parameters.
The starting color is black, the ending color is white, the angle is 45 degrees and the rectangle is located in (0,0) with size (1,1).
@Deprecated public ColorBlend getInterpolationColors()
Gets a com.aspose.imaging.ColorBlend that defines a multicolor linear gradient.
com.aspose.imaging.ColorBlend that defines a multicolor linear gradient.@Deprecated public void setInterpolationColors(ColorBlend value)
Sets a com.aspose.imaging.ColorBlend that defines a multicolor linear gradient.
value - A com.aspose.imaging.ColorBlend that defines a multicolor linear gradient.@Deprecated public Color[] getLinearColors()
Gets the starting and ending colors of the gradient.
Color structures that represents the starting and ending colors of the gradient.@Deprecated public void setLinearColors(Color[] value)
Sets the starting and ending colors of the gradient.
value - An array of two Color structures that represents the starting and ending colors of the gradient.public Color getStartColor()
Gets the starting gradient color.
public void setStartColor(Color value)
Sets the starting gradient color.
value - The starting gradient color.public Color getEndColor()
Gets the ending gradient color.
public void setEndColor(Color value)
Sets the ending gradient color.
value - The ending gradient color.public Blend getBlend()
Gets a Aspose.Imaging.Blend that specifies positions and factors that define a custom falloff for the gradient.
Aspose.Imaging.Blend that represents a custom falloff for the gradient.public void setBlend(Blend value)
Sets a Aspose.Imaging.Blend that specifies positions and factors that define a custom falloff for the gradient.
value - A Aspose.Imaging.Blend that represents a custom falloff for the gradient.public void setSigmaBellShape(float focus)
Creates a gradient falloff based on a bell-shaped curve.
focus - A value from 0 through 1 that specifies the center of the gradient (the point where the starting color and ending color are blended equally).public void setSigmaBellShape(float focus,
float scale)
Creates a gradient falloff based on a bell-shaped curve.
focus - A value from 0 through 1 that specifies the center of the gradient (the point where the gradient is composed of only the ending color).scale - A value from 0 through 1 that specifies how fast the colors falloff from the focus.public void setBlendTriangularShape(float focus)
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
focus - A value from 0 through 1 that specifies the center of the gradient (the point where the gradient is composed of only the ending color).public void setBlendTriangularShape(float focus,
float scale)
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
focus - A value from 0 through 1 that specifies the center of the gradient (the point where the gradient is composed of only the ending color).scale - A value from 0 through1 that specifies how fast the colors falloff from the starting color to focus (ending color)Copyright (c) 2008-2025 Aspose Pty Ltd. All Rights Reserved.