深度缩放宽高比返回错误值

时间:2011-02-18 18:57:24

标签: silverlight zoom

当图像为2000x1500 png时,我的MultiScaleImage返回的宽高比为1。更奇怪的是,xml元数据在宽高比标签中显示1.33,但其高度和宽度为1.

我在这里错过了什么?

感谢您的帮助!

的元数据:

<Metadata version="1">
  <AspectRatio>1.33333333333333</AspectRatio>
  <Image>
    <FileName>C:\Documents and Settings\asmith\Desktop\Temp\DZComposer\Testing1\Source Images\2000x1500 sample image.png</FileName>
    <x>0</x>
    <y>0</y>
    <Width>1</Width>
    <Height>1</Height>
    <ZOrder>1</ZOrder>
    <Tag />
  </Image>
</Metadata>

dzc_output.xml同意这一点:

<Collection MaxLevel="8" TileSize="256" Format="jpg" NextItemId="1" ServerFormat="Default" xmlns="http://schemas.microsoft.com/deepzoom/2009">
  <Items>
    <I Id="0" N="0" Source="dzc_output_images/2000x1500%20sample%20image.xml">
      <Size Width="2000" Height="1500" />
      <Viewport Width="1" X="-0" Y="-0" />
    </I>
  </Items>
</Collection>

MSI声明:

<MultiScaleImage 
  x:Name="msi" Grid.Column="1" Grid.Row="1" Width="720" Height="540"
  MouseMove="msi_MouseMove"
  MouseLeftButtonUp="msi_MouseLeftButtonUp">
</MultiScaleImage>

财产输出: (基于msi的mousemove)

宽度:720

身高:540

AspectRatio: 1

宽度/宽高比:720

逻辑X:0.55555555556

逻辑Y:0.37361111111

逻辑X *宽度:400

逻辑Y *宽度:269

原始X:400

原始Y:269

视口来源:0,0

视口宽度:1

填充属性输出的Codebehind:

private void msi_MouseMove(object sender, MouseEventArgs e)
{
  txtWidth.Text = msi.Width.ToString();
  txtHeight.Text = msi.Height.ToString();
  txtAspectRatio.Text = msi.AspectRatio.ToString();
  txtWidthDivAR.Text = (msi.Width / msi.AspectRatio).ToString();

  Point pLogical = msi.ElementToLogicalPoint(e.GetPosition(msi));
  txtMsiX.Text = pLogical.X.ToString();
  txtMsiY.Text = pLogical.Y.ToString();
  txtLogicYxW.Text = (pLogical.Y * msi.Width).ToString();
  txtLogicXxW.Text = (pLogical.X * msi.Width).ToString();

  Point pRaw = e.GetPosition(msi);
  txtRawX.Text = pRaw.X.ToString();
  txtRawY.Text = pRaw.Y.ToString();

  txtVPO.Text = msi.ViewportOrigin.ToString();
  txtVPW.Text = msi.ViewportWidth.ToString();
}

1 个答案:

答案 0 :(得分:0)

dzc_output.xml的宽度和高度是原始图像大小(以像素为单位),而元数据中的宽高比是MultiScaleImage的宽度和高度整体。元数据中图像的宽度和高度符合多尺度图像的大小。