BrushShader and CroppedBitmap tiling
Posted: 10 Sep 2022, 10:52
Looks like I managed to stumble upon a case that isn't supported (yet?).
I wanted to use an image from an atlas, tile it, and also change its color with a BrushShader.
And I found out that BrushShader works fine with either CroppedBitmap or tiling, but not both at the same time.
I'll probably just avoid CroppedBitmap for such scenarios, but is there anything I can do to make it work or the solution is simply "don't do this"? :)
(uses Nature.png from here https://www.noesisengine.com/xamltoy/71 ... a731aa1861 )
I wanted to use an image from an atlas, tile it, and also change its color with a BrushShader.
And I found out that BrushShader works fine with either CroppedBitmap or tiling, but not both at the same time.
I'll probably just avoid CroppedBitmap for such scenarios, but is there anything I can do to make it work or the solution is simply "don't do this"? :)
(uses Nature.png from here https://www.noesisengine.com/xamltoy/71 ... a731aa1861 )
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<Grid.Resources>
<BitmapImage x:Key="src" UriSource="Nature.png" />
<CroppedBitmap x:Key="Cropped" Source="{StaticResource src}" SourceRect="240,100,200,150" />
</Grid.Resources>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
<Label>Shader and Tile</Label>
<Rectangle Width="360" Height="240">
<Rectangle.Fill>
<ImageBrush ImageSource="{StaticResource Cropped}" TileMode="Tile" Viewport="0,0,0.5,0.5" >
<noesis:Brush.Shader>
<noesis:MonochromeBrushShader Color="White"/>
</noesis:Brush.Shader>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<Decorator Height="30" />
<Label>No Shader</Label>
<Rectangle Width="360" Height="240">
<Rectangle.Fill>
<ImageBrush ImageSource="{StaticResource Cropped}" TileMode="Tile" Viewport="0,0,0.5,0.5" />
</Rectangle.Fill>
</Rectangle>
<Decorator Height="30" />
<Label>No Tile</Label>
<Rectangle Width="360" Height="240">
<Rectangle.Fill>
<ImageBrush ImageSource="{StaticResource Cropped}" >
<noesis:Brush.Shader>
<noesis:MonochromeBrushShader Color="White"/>
</noesis:Brush.Shader>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
</StackPanel>
</Grid>