开发者

How can I create DrawingBrush from an image (BMP/JPEG/PNG)?

开发者 https://www.devze.com 2023-02-11 04:47 出处:网络
I need to pass DrawingBrush to a method in a third-party DLL which displays an image somewhere in the applica开发者_StackOverflow中文版tion. I can\'t modify this.

I need to pass DrawingBrush to a method in a third-party DLL which displays an image somewhere in the applica开发者_StackOverflow中文版tion. I can't modify this.

I need to create a DrawingBrush from an BMP Image. I tried this example but it doesn't work.

Any help would be appreciated.


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>

0

精彩评论

暂无评论...
验证码 换一张
取 消