Page 1 of 1

How to bypass the image cache when loading a BitmapImage from a file

Posted: 10 Aug 2020, 17:38
by frochet38
Hi,

I'm trying to display an image on some control, this works fine, but my image content changes based on user input.
I reload and refresh the user-interface using the code below :
	Noesis::Image* pImage = m_pMainWindow->FindName<Noesis::Image>("PhotoModiface");
	if (pImage != nullptr)
	{
		Noesis::BitmapImage* pBitmapImage = new Noesis::BitmapImage(szScreenShotFile.c_str());
		Noesis::Ptr<Noesis::ImageSource> pScreenShotImage = *pBitmapImage;
		pImage->SetSource(pScreenShotImage);
	}
The update works until I load an other XAML page, using GUI::LoadComponent, and then when
I reload back the page contaning the "PhotoModiface" image control, and refresh it using the above method, the image is always the one
loaded just before the page change, like if GUI::LoadComponent was caching the images based on their Uri.
Is there a way to bypass this cache ? I wasn't able to find how.

Thanks

Re: How to bypass the image cache when loading a BitmapImage from a file

Posted: 11 Aug 2020, 10:56
by jsantos
I assume you are installing your own TextureProvider. In that case, every time your filename is modified you can invoke
RaiseTextureChanged("MyImage.png");
and it will automatically reload.

Re: How to bypass the image cache when loading a BitmapImage from a file

Posted: 11 Aug 2020, 15:05
by frochet38
Thanks a lot, that's what I was looking for, seems to work well.

Re: How to bypass the image cache when loading a BitmapImage from a file

Posted: 11 Aug 2020, 16:37
by jsantos
Great!