christyjquinn
Topic Author
Posts: 17
Joined: 17 Aug 2022, 17:03

ImageBrush using local images flashes when initially loading

30 Aug 2022, 14:58

I have the following XAML to create a fullscreen background image where ImageSource is a relative path (local):
<Rectangle>
  <Rectangle.Fill>
    <ImageBrush Stretch="UniformToFill" ImageSource="{Binding ElementName=FullscreenModal, Path=ImageSource}" />
  </Rectangle.Fill>
</Rectangle>
When this loads it takes a moment and then appears, is there a way to pre-load/tell when the image source is ready to be displayed? This is being used for a fullscreen modal that we want to open once the image is loaded.
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: ImageBrush using local images flashes when initially loading

30 Aug 2022, 20:24

There are different ways to approach this:
  • First, we recommend implementing your own TextureProvider. And in that provider, you can pre-load textures that you know will be requested soon. That way, when Noesis resquests the texture it can be returned immediately
  • Second, we don't recommend using our FileTextureProvider in production (it is part of our Application Framework, our examples use it). That implementation if decoding image files and creating textures from them. Instead, you probably want to have all your textures already precreated (compressed, alpha-premultiplied) in a friendly format for the GPU. This is what are doing in our Unity and Unreal plugins.
  • And last, instead of binding an ImageSource, you can bind a TextureSource. Textures can be created from native handles using WrapTexture function available in our renderers or the equivalent one if you have your own renderer implementation.
 
christyjquinn
Topic Author
Posts: 17
Joined: 17 Aug 2022, 17:03

Re: ImageBrush using local images flashes when initially loading

01 Sep 2022, 10:43

Awesome, thanks for the pointers!

Who is online

Users browsing this forum: Ahrefs [Bot] and 20 guests