I need to pass DrawingBrush to a method in a third-party DLL which displays an image somewhere in the application. I can't modify this.
我需要将绘制刷传递给第三方DLL中的一个方法,该方法在应用程序的某个地方显示图像。我不能修改这个。
I need to create a DrawingBrush from an BMP Image. I tried this example but it doesn't work.
我需要从BMP映像创建一个绘制画笔。我试过这个例子,但是没用。
Any help would be appreciated.
如有任何帮助,我们将不胜感激。
1 个解决方案
#1
0
It should work.
它应该工作。
<Window x:Class="WpfApplication9.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" >
<Rectangle Height="100" Width="100">
<Rectangle.Fill>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing>
<GeometryDrawing.Brush>
<ImageBrush ImageSource="IC23839.jpg" />
</GeometryDrawing.Brush>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0 100,100" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
#1
0
It should work.
它应该工作。
<Window x:Class="WpfApplication9.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" >
<Rectangle Height="100" Width="100">
<Rectangle.Fill>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing>
<GeometryDrawing.Brush>
<ImageBrush ImageSource="IC23839.jpg" />
</GeometryDrawing.Brush>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0 100,100" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>