Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xaml.Media.Imaging.SurfaceImageSource variable margins #9800

Closed
tom-huntington opened this issue Jul 9, 2024 · 2 comments
Closed

Xaml.Media.Imaging.SurfaceImageSource variable margins #9800

tom-huntington opened this issue Jul 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tom-huntington
Copy link

tom-huntington commented Jul 9, 2024

Edit I realized the problem only reproduces if I have the Image in a ScrollViewer (i.e. the left margin is always 2px otherwise) and so don't care about this anymore.


Describe the bug

Tutorial on SurfaceImageSource for context.

ISurfaceImageSourceNative::BeginDraw returns a surface that is bigger than the pixelWidth and pixelHeight you parse to the SurfaceImageSource constructor.

The problem is that the left margin actually varies between different runs of the program. The top margin is always 0px. The right and bottom margins change in proportion with the hight and width.

If I translate my rendering with a left offset of 4px. I will get only my clear colour displayed some of the time. Other times I will get a pixel or two of SurfaceImageSource's clear colour 😢.

I can get the actual size from IDXGISurface::GetDesc but that doesn't help.

Maybe being a pixel or two off is not the end of the world.

Steps to reproduce the bug

<ScrollViewer HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Visible">
    <Image Margin="960,780,0,0" Stretch="None" x:Name="SentenceBySentenceImage"/>
</ScrollViewer>

NuGet package version

WinUI 3 - Windows App SDK 1.5.4: 1.5.240607001

@tom-huntington tom-huntington added the bug Something isn't working label Jul 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jul 9, 2024
@DarranRowe
Copy link

DarranRowe commented Jul 9, 2024

There is no here of whether or not the offset parameter is being used correctly. It is also true that the documentation for this parameter isn't good in the reference. The Windows.UI.Xaml version only describes it as "Receives the point (x,y) offset of the surface that will be drawn into." where the Microsoft.UI.Xaml version doesn't even document anything.
Looking at the DirectComposition documentation for IDCompositionSurface::BeginDraw and the Windows.UI.Composition ICompositionDrawingSurfaceInterop::BeginDraw provide some extra context for the parameter with the same name. That is, you need to offset your drawing rectangle by the x and y values given in the offset parameter.

@tom-huntington
Copy link
Author

Yes I forgot about the [out] POINT *updateOffset parameter.

Thanks!

@microsoft-github-policy-service microsoft-github-policy-service bot removed the needs-triage Issue needs to be triaged by the area owners label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants