BitmapDataFactoryCreateLinearGradient(Size, Single, Color32, Color32, WorkingColorSpace) Method
Creates a read-only bitmap data with no actual underlying buffer, containing a linear gradient that transitions between two colors along a straight line.
The line is specified by an angle only, and the actual start and end points are calculated automatically so they stretch
from one edge of the bitmap to the opposite edge.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.1
public static IReadableBitmapData CreateLinearGradient(
Size size,
float angle,
Color32 startColor,
Color32 endColor,
WorkingColorSpace workingColorSpace = WorkingColorSpace.Default
)
Public Shared Function CreateLinearGradient (
size As Size,
angle As Single,
startColor As Color32,
endColor As Color32,
Optional workingColorSpace As WorkingColorSpace = WorkingColorSpace.Default
) As IReadableBitmapData
public:
static IReadableBitmapData^ CreateLinearGradient(
Size size,
float angle,
Color32 startColor,
Color32 endColor,
WorkingColorSpace workingColorSpace = WorkingColorSpace::Default
)
static member CreateLinearGradient :
size : Size *
angle : float32 *
startColor : Color32 *
endColor : Color32 *
?workingColorSpace : WorkingColorSpace
(* Defaults:
let _workingColorSpace = defaultArg workingColorSpace WorkingColorSpace.Default
*)
-> IReadableBitmapData
- size Size
- The size, in pixels, of the bitmap data to create.
- angle Single
- The angle of the gradient line in degrees. The angle is measured clockwise from the positive x-axis.
- startColor Color32
- The color at the start of the gradient.
- endColor Color32
- The color at the end of the gradient.
- workingColorSpace WorkingColorSpace (Optional)
- The color space used for gradient interpolation. This parameter is optional.
Default value: Default, which means Srgb for this overload.
IReadableBitmapDataAn
IReadableBitmapData instance containing the generated linear gradient image.
This overload calculates the start/end points of the gradient automatically, which stretches from one edge to another.
To specify custom points, use the overloads with a startPoint and endPoint parameters.
In this overload the default value of workingColorSpace maps to WorkingColorSpace.Srgb, because
the Color32 type represents a color in the sRGB color space. When creating a monochromatic gradient, specifying Srgb can be better, because then the perceived
mid-tone brightness will be at the middle of the gradient. Otherwise, using Linear may be more appropriate, so the transition between the colors will seem more "natural".
Though the returned bitmap does not allocate an internal buffer and calculates every pixel dynamically when they are accessed,
operations on the result that return a new bitmap data (e.g.
Clone,
Resize,
ToGrayscale, etc.)
end up allocating a pixel buffer.