深度缩放纵横比返回错误值

发布于 2024-10-18 05:56:44 字数 2464 浏览 0 评论 0原文

当图像为 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

纵横比:1

宽度/纵横比:720

逻辑 X:0.55555555556

逻辑 Y:0.37361111111

逻辑 X * 宽度:400

逻辑 Y * 宽度:269

原始 X:400

原始 Y:269

视口原点:0,0

视口宽度:1

填充属性输出的代码隐藏:

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();
}

My MultiScaleImage is returning an aspect ratio of 1, when the image is a 2000x1500 png. What's even more odd, is that the xml metadata shows 1.33 in the aspect ratio tag, but then has a height and width of 1.

What the heck am I missing here?

Thanks for any help!

MetaData:

<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>

The dzc_output.xml agrees with this also:

<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 Declaration:

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

Property outputs:
(based on the msi's mousemove)

Width: 720

Height: 540

AspectRatio: 1

Width / Aspect Ratio: 720

Logical X: 0.55555555556

Logical Y: 0.37361111111

Logical X * Width: 400

Logical Y * Width: 269

Raw X: 400

Raw Y: 269

Viewport Origin: 0,0

Viewport Width: 1

Codebehind that populates property outputs:

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();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恏ㄋ傷疤忘ㄋ疼 2024-10-25 05:56:44

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

dzc_output.xml's width and height are original image size in pixels, while aspect ratio in metadata is width and height of MultiScaleImage as a whole. Width and height of image in metadata are logical to multiscaleimage's size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文