积极答复者
Windows Phone 7中的WriteableBitmap或者BitmapImage类如何裁剪及放大缩小某张图片?

问题
-
在Windows Form中,可以通过如下方法初始化一个新的Bitmap对象,其内容是原始图像bmp的某个矩形区域。
Bitmap temp = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(temp))
{
graphics.InterpolationMode =InterpolationMode.High;
graphics.SmoothingMode = SmoothingMode.HighQuality;
//清除整个绘图面并以透明背景色填充
graphics.Clear(Color.Transparent);
//在指定位置并且按指定大小绘制 原图片 对象
graphics.DrawImage(bmp, new Rectangle(0, 0, width, height), new Rectangle(left, 0, orgWidth, orgHeight), GraphicsUnit.Pixel);
}注:width height是裁剪后需要图像部分的大小。
orgWidth orgHeight 是原始bmp图片的大小。
那么在WP7 中将图像读入BitmapImage 或者 WriteableBitmap中后该如何实现上述效果?
答案
全部回复
-
不好意思刚看到你的回复。
如果网址打不开,可以到这个地址看能否直接下载项目
http://henry-chong.com/wp-content/uploads/2010/09/ImageCropper.zip
实在不行我再把程序发给你。
- 已建议为答案 Nathaniel.he 2014年4月15日 11:49