Page 1 of 1

ImageBrush works Abnormally in Noesis 3.1.1

Posted: 18 Sep 2021, 10:20
by zhangyi
ImageBrush does not work normally in Noesis 3.1.1,but works well in Noessis 3.0.12.

I give the following code in the Gallery demo,and it works differently in Noesis 3.1.1 and Noesis 3.0.12
<Rectangle Width="900" Height="600" Stroke="Black" StrokeThickness="1">
  <Rectangle.Fill>
    <ImageBrush ImageSource="Images/Nature.png" Stretch="None" Viewport="0,0,1,1" TileMode="Tile">
      <ImageBrush.Transform>
        <TranslateTransform X="0" Y="0"/>
      </ImageBrush.Transform>
    </ImageBrush>
  </Rectangle.Fill>
</Rectangle>
Noesis 3.0.12 shows:
3.0.12_res.PNG
3.0.12_res.PNG (186.7 KiB) Viewed 4655 times
Noesis 3.1.1 shows:
3.1.1_res.PNG
Any suggestion is appreciated.

Thanks!

Re: ImageBrush works Abnormally in Noesis 3.1.1

Posted: 20 Sep 2021, 10:42
by sfernandez
Hi, the behavior in 3.1 is correct compared to WPF where an Image with Stretch="None" and a Viewport="0,0,1,1" (entire target) leaves transparent border if image is smaller than target surface.
imgbrnone.jpg
If you want Tile to work, the Viewport should be smaller than the target surface:
<Rectangle Width="900" Height="600" Stroke="Black" StrokeThickness="1">
  <Rectangle.Fill>
    <ImageBrush ImageSource="Images/Nature.png" Stretch="UniformToFill" Viewport="0,0,0.5,0.5" TileMode="Tile">
      <ImageBrush.Transform>
        <TranslateTransform X="0" Y="0"/>
      </ImageBrush.Transform>
    </ImageBrush>
  </Rectangle.Fill>
</Rectangle>

Re: ImageBrush works Abnormally in Noesis 3.1.1

Posted: 20 Sep 2021, 15:40
by zhangyi
What should I do if I want the border part of the following picture?

And it should meets:
1. The base tile preserves original size.
2. The area that ImageBrush fills is not always rect, it is irregular sometimes
3.0.12_res.PNG
3.0.12_res.PNG (186.7 KiB) Viewed 4553 times

Re: ImageBrush works Abnormally in Noesis 3.1.1

Posted: 20 Sep 2021, 17:17
by sfernandez
Do you need the base tile centered in the area that ImageBrush should fill?
If that is the case, then you need to calculate the Viewport property of the ImageBrush based on the Image size and the area size. You can create a Converter that calculates it to assign the Viewport in XAML. Please let me know if you need help implementing this converter.