在WPF中,查看图像的一部分 [英] In WPF, view a portion of an image

查看:76
本文介绍了在WPF中,查看图像的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个图像,我们创建视图框坐标,这些坐标是图像中的多个/右下点,这些点设置为允许在我们的应用程序中的不同时间查看图像的某些部分。在WPF中,我们如何加载图像,并在该图像中使用topleft / right right point,仅显示该视图框中的图像部分?

We have an image where we create view box coordinates that are topleft/bottom right points within the image that are setup to allow for viewing portions of an image at different times in our application. In WPF, how do we load an image, and with topleft/bottom right points within that image, only show the portion of the image within that view box?

推荐答案

您可以使用CroppedBitmap执行此操作:

You can do this with a CroppedBitmap:

<Image>
  <Image.Source>
    <CroppedBitmap Source="<path to source image>" SourceRect="20,20,50,50"/>
  </Image.Source>
</Image>

这将显示从位置(20,20)开始的图像的50x50区域

This will display the 50x50 region of the image starting at position (20,20)

这篇关于在WPF中,查看图像的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆