Image rescale (downsize) with Silverlight
I have an array of graphs, that are 2000x1000 pixels pngs. When I put them into a silverlight Image that auto-sized with the browser window, DisplayImage.Source = new BitmapImage(GetHeatmapURL());
they images look distorted and for some browser sizes much worse than for some others.
I want to fiddle with some setting that would improve the quality of this downsampling, is this possible? Am I doing something wrong? My first approach was to put the Image into a Viewbox. That looked even worse. Googling gives virtually no开发者_运维百科thing useful...
Any help much appreciated.
PS. I'm working with Silverlight 4.
You could check out the WriteableBitmapEx project on CodePlex which gives you a Resize() extension method for the Silverlight WritableBitmap class where you can use either Bilinear or Nearest Neighbor interpolation. Resizing with the Bilinear interpolation might give you something that looks better than the ViewBox resizing, but you would have to test it out.
var resized = writeableBmp.Resize(200, 300, WriteableBitmapExtensions.Interpolation.Bilinear);
When making use of the Viewbox
you need to make sure to set Stretch
to Uniform
to respect the original height/width ratio.
In regards to the rendering of the image at the given aspect ratio and size; that is contingent on the framework.
精彩评论