unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.08k stars 736 forks source link

`ImageBrush` `Stretch="None"` doesn't work #4861

Open Xiaoy312 opened 3 years ago

Xiaoy312 commented 3 years ago

Current behavior

<ImageBrush Stretch="None" /> doesnt work.

How to reproduce it (as minimally and precisely as possible)

https://github.com/Xiaoy312/XyPoB/tree/bug/samples/uno-sprite-sheet-image-brush

<Rectangle Grid.Row="1"
           Grid.Column="1"
           Width="26"
           Height="32">
    <Rectangle.Fill>
        <ImageBrush ImageSource="/Assets/test_image_100_100.png"
                    AlignmentX="Left"
                    AlignmentY="Top"
                    Stretch="None">
            <ImageBrush.Transform>
                <TranslateTransform X="-35" Y="-33" />
            </ImageBrush.Transform>
        </ImageBrush>
    </Rectangle.Fill>
</Rectangle>
just compile and run the app uwp android ios wasm
image image image image

Workaround

paint/draw the control yourself: https://github.com/Xiaoy312/XyPoB/blob/bug/samples/uno-sprite-sheet-image-brush/src/XyPoB.Shared/Controls/Sprite.cs#L89 or, use multiple images instead of a sprite-sheet.

Environment

Nuget Package:

Nuget Package Version(s): 3.5.0-dev.16

Affected platform(s):

IDE:

Relevant plugins:

Anything else we need to know?

Youssef1313 commented 3 years ago

The links are dead. @Xiaoy312 Do you still have the sample project?

Xiaoy312 commented 3 years ago

Sorry, it appears that I've scrapped the project... I can't even find a trace of it on my machine :| However, you should be able to jsut reproduce it with just that xaml snippet. Of note, the image file can be found here: https://github.com/unoplatform/uno/blob/master/src/SamplesApp/UITests.Shared/Assets/test_image_100_100.png

GitHub
uno/test_image_100_100.png at master · unoplatform/uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported. - uno/test_image_100_100.png at master · unoplatform/uno