本文整理汇总了C#中RenderTarget.CreateSolidColorBrush方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.CreateSolidColorBrush方法的具体用法?C# RenderTarget.CreateSolidColorBrush怎么用?C# RenderTarget.CreateSolidColorBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.CreateSolidColorBrush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PDirect2DRenderer
public PDirect2DRenderer(IntPtr winHandle)
{
fWindowHandle = winHandle;
CreateFactories();
CreateDeviceResources();
Graphics = hwndRenderTarget;
fStrokeBrush = Graphics.CreateSolidColorBrush(new ColorF(0, 0, 0, 1));
fFillBrush = Graphics.CreateSolidColorBrush(new ColorF(1, 1, 1, 1));
}
示例2: UserDrawingDelegate
private void UserDrawingDelegate(RenderTarget target)
{
if (showLiveRectangleFlag)
{
target.DrawRectangle(new RectF(liveRectangleOrigin.X, liveRectangleOrigin.Y, liveRectangleOrigin.X + liveRectangleSize.Width, liveRectangleOrigin.Y + liveRectangleSize.Height), target.CreateSolidColorBrush(new ColorF(Color.Red.ToArgb())), 1);
}
if (sampleColor)
{
int dif = 5;
Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Brush brush = target.CreateSolidColorBrush(new ColorF(Color.Red.ToArgb()));
Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F p1 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X - dif, sampleLocation.Y);
Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F p2 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X + dif, sampleLocation.Y);
target.DrawLine(p1, p2, brush, 1);
p1 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X, sampleLocation.Y - dif);
p2 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X, sampleLocation.Y + dif);
target.DrawLine(p1, p2, brush, 1);
}
}
示例3: CreateBackBufferD2DRenderTarget
private void CreateBackBufferD2DRenderTarget()
{
// Get a surface in the swap chain
using (Surface backBufferSurface = swapChain.GetBuffer<Surface>(0))
{
backBufferRenderTarget = d2DFactory.CreateGraphicsSurfaceRenderTarget(
backBufferSurface,
renderTargetProperties
);
GradientStopCollection stops = backBufferRenderTarget.CreateGradientStopCollection(stopsBackground,
Gamma.StandardRgb,
ExtendMode.Mirror);
backBufferGradientBrush = backBufferRenderTarget.CreateLinearGradientBrush(
new LinearGradientBrushProperties(
new Point2F(0.0f, 0.0f),
new Point2F(0.0f, 1.0f)),
stops);
// Create a red brush for text drawn into the back buffer
backBufferTextBrush = backBufferRenderTarget.CreateSolidColorBrush(new ColorF(GetColorValues(System.Windows.Media.Colors.WhiteSmoke)));
}
}
示例4: CreateD2DRenderTargets
private void CreateD2DRenderTargets()
{
// Create a D2D render target which can draw into our offscreen D3D surface
textureRenderTarget = d2DFactory.CreateGraphicsSurfaceRenderTarget(
textureSurface,
renderTargetProperties
);
// Create a linear gradient brush for the 2D geometry
GradientStopCollection gradientStops = textureRenderTarget.CreateGradientStopCollection(stopsGeometry, Gamma.StandardRgb, ExtendMode.Mirror);
linearGradientBrush = textureRenderTarget.CreateLinearGradientBrush(
new LinearGradientBrushProperties(
new Point2F(100, 0),
new Point2F(100, 200)),
gradientStops
);
// create a black brush
blackBrush = textureRenderTarget.CreateSolidColorBrush(new ColorF(GetColorValues(System.Windows.Media.Colors.Black)));
using (Stream stream = Application.ResourceAssembly.GetManifestResourceStream("Microsoft.WindowsAPICodePack.DirectX.Samples.tulip.jpg"))
{
d2dBitmap = BitmapUtilities.LoadBitmapFromStream(
textureRenderTarget,
imagingFactory,
stream);
}
gridPatternBitmapBrush = CreateGridPatternBrush(textureRenderTarget);
gridPatternBitmapBrush.Opacity = 0.5f;
CreateBackBufferD2DRenderTarget();
}
示例5: CopyBrushToRenderTarget
/// <summary>
/// Creates and returns a copy of the brush in the new render target.
/// Used for changing render targets.
/// A brush belongs to a render target, so when you want to draw with same brush in another render target
/// - you need to create a copy of the brush in the new render target.
/// </summary>
/// <param name="sourceBrush">The brush.</param>
/// <param name="newRenderTarget">The new render target.</param>
/// <returns></returns>
protected internal Brush CopyBrushToRenderTarget(Brush sourceBrush, RenderTarget newRenderTarget)
{
if (sourceBrush == null || newRenderTarget == null)
return null;
Brush newBrush;
if (sourceBrush is SolidColorBrush)
{
newBrush = newRenderTarget.CreateSolidColorBrush(
((SolidColorBrush)sourceBrush).Color,
new BrushProperties(sourceBrush.Opacity, sourceBrush.Transform));
sourceBrush.Dispose();
return newBrush;
}
if (sourceBrush is LinearGradientBrush)
{
var oldGSC = ((LinearGradientBrush)sourceBrush).GradientStops;
var newGSC = newRenderTarget.CreateGradientStopCollection(oldGSC, oldGSC.ColorInterpolationGamma, oldGSC.ExtendMode);
oldGSC.Dispose();
newBrush = newRenderTarget.CreateLinearGradientBrush(
new LinearGradientBrushProperties(
((LinearGradientBrush)sourceBrush).StartPoint,
((LinearGradientBrush)sourceBrush).EndPoint),
newGSC,
new BrushProperties(sourceBrush.Opacity, sourceBrush.Transform));
sourceBrush.Dispose();
return newBrush;
}
if (sourceBrush is RadialGradientBrush)
{
var oldGSC = ((RadialGradientBrush)sourceBrush).GradientStops;
var newGSC = newRenderTarget.CreateGradientStopCollection(oldGSC, oldGSC.ColorInterpolationGamma, oldGSC.ExtendMode);
oldGSC.Dispose();
newBrush = newRenderTarget.CreateRadialGradientBrush(
new RadialGradientBrushProperties(
((RadialGradientBrush)sourceBrush).Center,
((RadialGradientBrush)sourceBrush).GradientOriginOffset,
((RadialGradientBrush)sourceBrush).RadiusX,
((RadialGradientBrush)sourceBrush).RadiusY),
newGSC,
new BrushProperties(sourceBrush.Opacity, sourceBrush.Transform));
sourceBrush.Dispose();
return newBrush;
}
if (sourceBrush is BitmapBrush)
{
newBrush = newRenderTarget.CreateBitmapBrush(
Bitmap,
new BitmapBrushProperties(
((BitmapBrush)sourceBrush).ExtendModeX,
((BitmapBrush)sourceBrush).ExtendModeY,
((BitmapBrush)sourceBrush).InterpolationMode),
new BrushProperties(sourceBrush.Opacity, sourceBrush.Transform));
sourceBrush.Dispose();
return newBrush;
}
throw new NotImplementedException("Unknown brush type used");
}