kayrk
Topic Author
Posts: 41
Joined: 07 May 2014, 19:41

Grid Background Image

07 May 2014, 19:50

Maybe I'm doing something wrong here but once I set an ImageBrush for Grid.Background the background is really blury. I've tried all type of fills such as fill, uniform fill, none etc. still the image is blury.
    	
<Grid.Background>  
     <ImageBrush ImageSource="Resources/bg.png" Stretch="UniformToFill"/>     
</Grid.Background>
Cropped image on the right shows what the quality of the image should look like.
Image

Any help with this is appreciated.
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Grid Background Image

07 May 2014, 19:54

For efficiency and compatibility reasons image dimensions are converted to power of two before being converted to textures. The blurriness can be avoided if your image has already that format.
 
kayrk
Topic Author
Posts: 41
Joined: 07 May 2014, 19:41

Re: Grid Background Image

07 May 2014, 21:05

These are the settings I have for my image are these correct? I still am getting blurriness.

Image
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Grid Background Image

07 May 2014, 22:32

Stretch must be set to None. Besides that, we don't use the parameters passed in the Unity importer for images, we use our own algorithm to mimic WPF behavior. It seems that your texture is 2048 x 1024, I have done a quick test with an image of similar dimensions:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" UseLayoutRounding="True">
    <Grid.Background>
        <ImageBrush ImageSource="bg.jpg" Stretch="None" AlignmentX="Center" AlignmentY="Center"/>
    </Grid.Background>
</Grid>
And the result is quite acceptable. Little artifacts due to texture compression but good quality. Could you test with this XAML?

If the result is still incorrect, I am going need to have a look at that image. If you don't want to share it publicly you can file a bug with it.
 
kayrk
Topic Author
Posts: 41
Joined: 07 May 2014, 19:41

Re: Grid Background Image

07 May 2014, 23:28

The image is actually 1920x1080. Wouldn't I need to use a stretch setting so it would work for any resolution? Here is the http://www.roguereturns.com/background.png
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Grid Background Image

08 May 2014, 03:52

Yes, in case you want to support any resolution you need to use UniformToFill.

The differences between Unity and noesisGUI are due to the bilinear setting you are using in the Unity image importer. With this settings Unity avoids using mipmaps. This way you get sharper images but with the risk of generating aliasing. For example, you can try to reduce the image by a high factor and you will see that the result is not acceptable.

If you activate trilinear in Unity you will see that the result is similar to noesisGUI default. In this case the aliasing is fought by adding blurriness. For now, we don't have option for chaging this behaviour. We should implement the attached property RenderOptions.BitmapScalingMode. For example:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" UseLayoutRounding="True"
  RenderOptions.BitmapScalingMode="LowQuality"
  >
    <Grid.Background >
        <ImageBrush ImageSource="background.png" Stretch="UniformToFill" AlignmentX="Center" AlignmentY="Center"/>
    </Grid.Background>
</Grid>
If this is important to you please, file us a bug to prioritize this task. Although, as said, in this option extra aliasing is generated (note that WPF calls this mode LowQuality)
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Grid Background Image

20 May 2014, 18:49

Fixed in v1.1.8

Who is online

Users browsing this forum: Bing [Bot] and 2 guests