c# - WPF Image RenderOptions.BitmapScalingMode.LowQuality consumes 10x more memory than HighQuality -


i have image 5k x 5k pixels.
image contains layouttransform scaletransform.

<image x:name="image" source="{binding imagesource, mode=oneway}" width="{binding imagewidth, mode=oneway}" height="{binding imageheight, mode=oneway}" visibility="{binding imagevisibility, mode=oneway}" renderoptions.bitmapscalingmode="highquality" renderoptions.edgemode="aliased">      <image.layouttransform>           <scaletransform  scalex="{binding scalevalue, mode=oneway}" scaley="{binding scalevalue, mode=oneway}"/>      </image.layouttransform> </image> 

since scaling image slow due highquality option, decided set lowquality during scaling process. turns out lowquality option consumes more memory highquality can see in screenshot.

renderoptions.setbitmapscalingmode(image, bitmapscalingmode.lowquality); //reduce quality during resize improve performance (or not :() 


the memory peak after setting low not temporary - stays until application closed. second or third resize operation has no effect on peak.

believe image control caches image of sort - not sure though.
familliar memory leak can happen if bitmapimage not manually destroyed think not problem here since peak happens during renderoption-change.

any ideas appreciated

edit
code use load image:

stream imagestreamsource = new filestream(_filepath, filemode.open, fileaccess.read, fileshare.read); tiffbitmapdecoder decoder = new tiffbitmapdecoder(imagestreamsource, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload);  bitmapsource bmsrc = decoder.frames[0]; bmsrc.freeze();  imagesource = bmsrc; 

enter image description here


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -