0

Right now I have a ScrollViewer control in a Windows Store Application which surrounds an Image element. I am trying to make a pixel art editor but when the ScrollViewer is zoomed in the Image's contents are interpolated. Is there currently any way to force the image to be scaled in nearest neighbor mode?

EDIT: I decided I should put some code to clarify what I'm trying to do, so here it is:

<ScrollViewer
    x:Name="Container"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    ZoomMode="Enabled"
    MinZoomFactor="0.1"
    MaxZoomFactor="100"
    HorizontalScrollMode="Enabled"
    HorizontalScrollBarVisibility="Auto"
    VerticalScrollMode="Enabled"
    VerticalScrollBarVisibility="Auto"
    ViewChanged="OnContainerViewChanged">
    <Border
        x:Name="ImageBorder"
        Width="32"
        Height="32"
        BorderBrush="White"
        BorderThickness="4">
        <Grid>
            <Image
                x:Name="RenderedImage"/>
            <Image
                x:Name="EditPreview"/>
            <Canvas
                x:Name="GridContainer"
                Visibility="Collapsed"/>
            <Rectangle
                x:Name="InputCapturer"
                Fill="Transparent"
                PointerPressed="OnPointerPressed"
                PointerMoved="OnPointerMoved"
                PointerReleased="OnPointerReleased"
                PointerExited="OnPointerLeave"/>
        </Grid>
    </Border>
</ScrollViewer> 
  • Just a quick clarification, is this for a 8 or 8.1? – Nate Diamond Feb 19 '14 at 23:17
  • I *think* what you may need to do is to create a BitmapEncoder which on-the-fly rescales the images in the background. Check out what is being done [here](http://stackoverflow.com/questions/11385000/xaml-image-quality-interpolation-in-a-metro-style-app). I think you can store the copy of the Encoder as a class variable, then on ViewChanged, change the scale width/height to the new width/height and re-flush. You may have to play around with the stream seeking to get it to work. I don't know if you'll have to re-set the source. – Nate Diamond Feb 19 '14 at 23:28
  • @NateDiamond This is for 8.1, and I'll check out your suggestion and report back if it works. – user2746573 Feb 22 '14 at 02:25

0 Answers0