10-09-2015, 11:19 AM
I am trying to calcualte the correct zoomlevel for an Image inside a Zoompanel.
How do I calculate the actual zoom of my Image inside the Image control - at any ZoomPanel and Image aspect ratio and size. (zoom = display-pixelwidth of 1 image pixel).
The ZoomFactor is constant while resizing a Zoompanel. The amount of pixels shown in the encapsuled Image control is often kept constant, but sometimes it increase or decrease (especially seen when having a very asymmetric ZoomPanel control). Therefore I cannot calculate the actual zoomfactor (1 pixel in the Image takes up X pixels on the display).
I use "ZoomPanel.GetZoomFactor(viewbox)" or simply the "ZoomFactor" property to get the zoomfactor (which is not updated when the ViewboxChanged event is fired unfortunately).
The ZoomPanel is inside a grid with "*" row width and column height so it resizes with window resize.
xaml:
<ab2d:ZoomPanel
Grid.Row="0"
Name="ZoomPanel" Margin="5,0,5,0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
MouseRightButtonDown="ZoomPanel_MouseRightButtonDown" MouseRightButtonUp="ZoomPanel_MouseRightButtonUp"
MouseMove="ZoomPanel_MouseMove" ViewboxChanged="ZoomPanel_ViewboxChanged"
IsViewboxLimited="True" ViewboxMinSize="0.0078125, 0.0078125" ViewboxLimits="0, 0, 1, 1"
RenderOptions.BitmapScalingMode="NearestNeighbor"
ZoomMode="Move" ZoomFactor="1" Stretch="Uniform">
<Grid>
<Image Source="{Binding BS}" Cursor="Cross" Name="ZoomImage" Panel.ZIndex="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<Canvas Name="Overlay" Panel.ZIndex="5" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Visibility="{Binding ShowOverlay, Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False"/>
</Grid>
</ab2d:ZoomPanel>
How do I calculate the actual zoom of my Image inside the Image control - at any ZoomPanel and Image aspect ratio and size. (zoom = display-pixelwidth of 1 image pixel).
The ZoomFactor is constant while resizing a Zoompanel. The amount of pixels shown in the encapsuled Image control is often kept constant, but sometimes it increase or decrease (especially seen when having a very asymmetric ZoomPanel control). Therefore I cannot calculate the actual zoomfactor (1 pixel in the Image takes up X pixels on the display).
I use "ZoomPanel.GetZoomFactor(viewbox)" or simply the "ZoomFactor" property to get the zoomfactor (which is not updated when the ViewboxChanged event is fired unfortunately).
The ZoomPanel is inside a grid with "*" row width and column height so it resizes with window resize.
xaml:
<ab2d:ZoomPanel
Grid.Row="0"
Name="ZoomPanel" Margin="5,0,5,0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
MouseRightButtonDown="ZoomPanel_MouseRightButtonDown" MouseRightButtonUp="ZoomPanel_MouseRightButtonUp"
MouseMove="ZoomPanel_MouseMove" ViewboxChanged="ZoomPanel_ViewboxChanged"
IsViewboxLimited="True" ViewboxMinSize="0.0078125, 0.0078125" ViewboxLimits="0, 0, 1, 1"
RenderOptions.BitmapScalingMode="NearestNeighbor"
ZoomMode="Move" ZoomFactor="1" Stretch="Uniform">
<Grid>
<Image Source="{Binding BS}" Cursor="Cross" Name="ZoomImage" Panel.ZIndex="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<Canvas Name="Overlay" Panel.ZIndex="5" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Visibility="{Binding ShowOverlay, Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False"/>
</Grid>
</ab2d:ZoomPanel>