Why is my image being displayed larger?

Posted by bsh152s on Stack Overflow See other posts from Stack Overflow or by bsh152s
Published on 2012-06-05T16:23:15Z Indexed on 2012/06/05 16:40 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

I'm trying to display an image on a splash screen and it's being stretched upon display. The image I'm trying to display is a simple bmp file. Any ideas why?

In SplashWindow.xaml:

<Window ... SizeToContent="WidthAndHeight">
  <Grid>
    ...
    <Image Grid.Row="0" Source="{Binding SplashImage}"></Image>
  </Grid>
</Window>

In SplashViewModel.cs

public ImageSource SplashImage
{
  get
  {
    return ImageUtilities.GetImageSource(_splashImageFilenameString);
  }
}

From ImageUtilities.cs

public static ImageSource GetImageSource(string imageFilename)
{
  BitmapFrame bitmapFrame = null;

  if(!string.IsNullOrEmpty(imageFilename))
  {
    if(File.Exists(imageFilename))
    {
      bitmapFrame = BitmapFrame.Create(new Uri(imageFilename));
    }
    else
    {
      Debug.Assert(false, "File " + imageFilename + " does not exist.");
    }
  }
  return bitmapFrame;
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf