zhangyi
Topic Author
Posts: 9
Joined: 09 Jul 2016, 09:31

ImageBrush works Abnormally in Noesis 3.1.1

18 Sep 2021, 10:20

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 1789 times
Noesis 3.1.1 shows:
3.1.1_res.PNG
Any suggestion is appreciated.

Thanks!
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: ImageBrush works Abnormally in Noesis 3.1.1

20 Sep 2021, 10:42

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>
 
zhangyi
Topic Author
Posts: 9
Joined: 09 Jul 2016, 09:31

Re: ImageBrush works Abnormally in Noesis 3.1.1

20 Sep 2021, 15:40

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 1687 times
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: ImageBrush works Abnormally in Noesis 3.1.1

20 Sep 2021, 17:17

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.

Who is online

Users browsing this forum: Google [Bot] and 84 guests