MultiDensityImage

Hi guys, i’m trying to use MultiDensityImage with no luck.

<Image StretchMode="PointPrefer">
    <MultiDensityImageSource>
        <FileImageSource File="Assets/Pelota@1x.png" Density="1"/>
        <FileImageSource File="Assets/Pelota@2x.png" Density="2"/>
    </MultiDensityImageSource>
</Image>
<Image StretchMode="PointPrefer" File="Assets/Pelota@1x.png"/>

I’ve added the second image just to try a normal image. The result was this:

file

The big ball is the normal image, the small ball is the multidensity image. On @Jake suggestion, i’ve tried this:

<MultiDensityImageSource ux:Global="imageSource">
    <FileImageSource File="Assets/Pelota@1x.png" Density="1"/>
    <FileImageSource File="Assets/Pelota@2x.png" Density="2"/>
</MultiDensityImageSource>
<Image StretchMode="PointPrefer" Source="imageSource"/>

but i get Argument cannot be null. Parameter name: key

I’m testing on an iphone6s with iOS 9.3.1, fuse 0.12.3

Hi guys, any news on this?

I’m not sure where the suggestion to remove the <Image>-tag comes from, but that’s not expected to work (although I don’t think it should error this particular way).

As for the first issue, I’m not entirely sure what problem you’re trying to show.

If the device has a density of 2, and you show both Assets/Pelota@2x.png with PointPrefer and Assets/Pelota@1x.png, then you’ll get two differently sized images, as the image shows.

I think you want to set StretchMode="PixelPrecise"