1

Topic: [WPF] RenderOptions it is ignored

Greetings to all! Wanted to make a picture  in which the background represents RadialGradientBrush. After saving in format PNG saw that passage as though smooth, but during too time steps are visible. Thought all business in RenderOptions, but it does not work!!! I put BitmapScalingMode. NearestNeighbor, and I receive the same curve smoothing though it was expected that smoothing at all will not be!!! <UserControl x:Class = "WpfApplication2.UserControl1" xmlns = "http://schemas.microsoft.com/winfx/2006 … esentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc = "http://schemas.openxmlformats.org/marku … ility/2006" xmlns:d = "http://schemas.microsoft.com/expression/blend/2008" xmlns:local = "clr-namespace:WpfApplication2" Height = "220" Width = "420"> <UserControl. Resources> <RadialGradientBrush x:Key = "radialBrush" Center = "0.5 0.5" RadiusX = "1" RadiusY = "0.6"> <GradientStop Color = "#FF4FB63F" Offset = "0"/> <GradientStop Color = "#FF429338" Offset = "0.2"/> <GradientStop Color = "#FF0C2B07" Offset = "0.7"/> <GradientStop Color = "#FF0C2B07" Offset = "1"/> </RadialGradientBrush> </UserControl. Resources> <Grid Background = "{StaticResource radialBrush}"/> </UserControl> private void Save (string filename, int scale) {RenderTargetBitmap render = new RenderTargetBitmap (420 * scale, 220 * scale, 96 * scale, 96 * scale, PixelFormats. Pbgra32); render. Render (control); render. SetValue (RenderOptions. BitmapScalingModeProperty, BitmapScalingMode. NearestNeighbor); TransformedBitmap transform = new TransformedBitmap (render, new ScaleTransform (0.5, 0.5, 0, 0)); transform. SetValue (RenderOptions. BitmapScalingModeProperty, BitmapScalingMode. NearestNeighbor); PngBitmapEncoder png = new PngBitmapEncoder (); png. Frames. Add (BitmapFrame. Create (transform)); using (FileStream stream = new FileStream (string. Format ("{0} _ {1}.png", filename, scale), FileMode. Create, FileAccess. Write, FileShare. Read)) {png. Save (stream);}}

2

Re: [WPF] RenderOptions it is ignored

Hello, SanyaVB, you wrote: Try to change to begin with these lines in places. SVB> render. Render (control); SVB> render. SetValue (RenderOptions. BitmapScalingModeProperty, BitmapScalingMode. NearestNeighbor);