惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
博客园 - 聂微东
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
F
Fortinet All Blogs
H
Help Net Security
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
L
LangChain Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium

博客园 - 悟空空

Firefox IE兼容性js笔记 Firefox,Safari与IE兼容性问题整理 在cs类中调用嵌入资源并输出流 - 悟空空 - 博客园 调用dll给winform程序创建所有用户均可使用的快捷方式 SQL Server获取TEXT字段的内容长度 正则表达式笔记 Silverlight 4简体中文正式版脱机帮助文档安装说明 [原创]利用CPAU静默调用其它程序 - 悟空空 - 博客园 CPAU参数说明 - 悟空空 - 博客园 apache_2.2.4和php-5.3.2安装过程问题整理 Rectangle 属性 SSL网站自动安装根目录证书(整理备用)javascript - 悟空空 - 博客园 NND年年回家这么难买火车票 DoubleAnimation 类 Storyboard 类 - 悟空空 - 博客园 Windows Presentation Foundation 中的 Pack URI WPF 性能分析工具 CompositionTarget 类 SolidColorBrush 类 - 悟空空 - 博客园
CroppedBitmap 类
悟空空 · 2010-01-18 · via 博客园 - 悟空空

CroppedBitmap 类

更新:2007 年 11 月

命名空间:  System.Windows.Media.Imaging
程序集:  PresentationCore(在 PresentationCore.dll 中)

CroppedBitmap 实现 ISupportInitialize 接口,以对多个属性的初始化进行优化。只能在对象初始化过程中对属性进行更改。调用 BeginInit 以表示初始化开始;调用 EndInit 以表示初始化结束。初始化后,将忽略属性更改。

使用 CroppedBitmap(BitmapSource, Int32Rect) 构造函数创建的 CroppedBitmap 对象将自动初始化,且属性无法更改。

如果在应用转换后将图像保存到文件,则必须更新与图像数据相关的元数据标记。

使用此类的 SourceRect 属性定义要裁剪的位图区域。

// Create an Image element.
Image croppedImage = new Image();
croppedImage.Width = 200;
croppedImage.Margin = new Thickness(5);

// Create a CroppedBitmap based off of a xaml defined resource.
CroppedBitmap cb = new CroppedBitmap(     
   (BitmapSource)this.Resources["masterImage"],
   new Int32Rect(30, 20, 105, 50));       //select region rect
croppedImage.Source = cb;                 //set image source to cropped

CroppedBitmap 还可以用作另一个 CroppedBitmap 的源,从而链接裁剪内容。请注意,SourceRect 使用相对于源裁剪位图的值,而不是使用相对于初始图像的值。