开发者

Refresh BitmapCache?

开发者 https://www.devze.com 2023-02-09 10:03 出处:网络
How do I refresh a BitmapCache in WPF? When I apply a BitmapCache, it stretches the window content I cached when I change the wi开发者_如何转开发ndow size.

How do I refresh a BitmapCache in WPF? When I apply a BitmapCache, it stretches the window content I cached when I change the wi开发者_如何转开发ndow size.

I need to know in either C# or VB .NET.


Depending on how much the window size is growing by, you could try using the "RenderAtScale" attribute, e.g. (xaml):

<Path ...>
    <Path.CacheMode>
        <BitmapCache RenderAtScale="2"/>
    </Path.CacheMode>
</Path>

(C#):

Path path = new Path();
BitmapCache bitmapCache = new BitmapCache();
bitmapCache.RenderAtScale = 2;
path.CacheMode = bitmapCache;   

This would cache the path at twice its original size, meaning that it shouldn't look fuzzy when scaled up.

I know this isn't what you asked to do but it might solve your problem.


http://blogs.msdn.com/b/llobo/archive/2009/11/10/new-wpf-features-cached-composition.aspx

In the above link it says:

"Note that changing the UIElement subtree or these properties (EnableClearType\RenderAtScale) will cause the cache to be regenerated."

So everytime the window is stretched, do one of the above to cause the cache to be regenerated/refreshed - I would imagine flipping the EnableClearType= property would be the simplest to try first.

0

精彩评论

暂无评论...
验证码 换一张
取 消