Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize image in xaml without losing quality

Tags:

c#

image

xaml

I have this image (original size: 256x256)

enter image description here

I made this xaml definition to show the image in my application

<Image Grid.Row="1"         Source="/MyProject;component/Images/happy.png"         Stretch="Fill"         Width="64" Height="64"          VerticalAlignment="Top" Margin="0,0,0,0"         HorizontalAlignment="Center" /> 

And I get this result

enter image description here

How can I made a more smooth resize?

like image 760
Naty Bizz Avatar asked Oct 10 '13 17:10

Naty Bizz


People also ask

How do I resize and not lose quality?

If you want to resize an image without losing quality, you need to make sure that the "Resample" checkbox is unchecked. This checkbox tells Paint to change the number of pixels in the image. When you uncheck this box, Paint will not change the number of pixels, and the quality of the image will not be reduced.

Does downsizing an image reduce quality?

The most common side effect of scaling an image larger than its original dimensions is that the image may appear to be very fuzzy or pixelated. Scaling images smaller than the original dimensions does not affect quality as much, but can have other side effects.

How do I resize an image in Visual Studio?

Open the image whose properties you want to change. In the Width and Height boxes in the Properties window, type the dimensions that you want. If you're increasing the size of the image, the Image Editor extends the image to the right, downward, or both, and fills the new region with the current background color.


1 Answers

Include RenderOptions.BitmapScalingMode="Fant" on your Image, like so:

<Image Grid.Row="1"        Source="/MyProject;component/Images/happy.png"        RenderOptions.BitmapScalingMode="Fant"        Stretch="Fill"        Width="64"        Height="64"        VerticalAlignment="Top"        Margin="0,0,0,0"        HorizontalAlignment="Center" /> 
like image 183
Daniel Avatar answered Sep 30 '22 16:09

Daniel