//StorageFolder savedPics = ApplicationData.Current.LocalFolder;
//BitmapImage bi = new BitmapImage();

//RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
//await renderTargetBitmap.RenderAsync(GridImage);

//IBuffer buffer = await renderTargetBitmap.GetPixelsAsync();
//StorageFile newfile = await savedPics.CreateFileAsync("snap.jpg", CreationCollisionOption.ReplaceExisting);
//using (var writeStream = await newfile.OpenAsync(FileAccessMode.ReadWrite))
//{
// BitmapEncoder jpgencode = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, writeStream);
// byte[] data = buffer.ToArray();

// Rect temp = MeasureUtil.GetBounds(GridImage, LayoutRoot);

// jpgencode.BitmapTransform.Bounds = new BitmapBounds
// {
// X = (uint)Math.Round((measureRect.X - temp.X), 0),
// Y = (uint)Math.Round((measureRect.Y - temp.Y), 0),
// Width = (uint)Math.Round(measureRect.Width, 0),
// Height = (uint)Math.Round(measureRect.Height, 0)
// };

// jpgencode.SetPixelData(
// BitmapPixelFormat.Bgra8,
// BitmapAlphaMode.Straight,
// (uint)renderTargetBitmap.PixelWidth,
// (uint)renderTargetBitmap.PixelHeight,
// 96d, 96d, data);

// bi.SetSource(writeStream);

// // 如果需要设置图片的固定宽、高,可以使用 WriteableBitmap 对象
// //WriteableBitmap wb = new WriteableBitmap(480, 480);
// //wb.SetSource(WriteStream);
// //imgResult.Source = wb;

// await jpgencode.FlushAsync();
//}

RenderTargetBitmap render = new RenderTargetBitmap();
await render.RenderAsync(CroppedImage);

IBuffer pixelBuffer = await render.GetPixelsAsync();

StorageFolder fold = ApplicationData.Current.LocalFolder;
StorageFile file = await fold.CreateFileAsync("save.jpg", CreationCollisionOption.ReplaceExisting);

using (var randstream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi;
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, randstream);
encoder.SetPixelData(
BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Ignore,
(uint)render.PixelWidth,
(uint)render.PixelHeight,
logicalDpi,
logicalDpi,
pixelBuffer.ToArray());

await encoder.FlushAsync();

}

Win10 for Phone 裁剪保存的更多相关文章

  1. Win10 hosts文件无法保存

    Win10无法修改编辑保存hosts文件怎么办?Win10系统默认是没有权限去编辑保存系统里的文件,这也是权限不够才导致修改编辑hosts后无法保存的原因,解决的办法就是把自己的帐户权限给提高就行了. ...

  2. mono for android 获取手机照片或拍照并裁剪保存

    axml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...

  3. Win10注册表无法保存对权限所作的更改拒绝访问

    在对系统的安全控制得越来越多的情况下,要对注册表的关键数据进行修改是件挺麻烦的事,时不时会弹出无法保存对xxxxxx权限所作的更改,拒绝访问,操作产生错误,操作出现错误的提示,这时怎么办呢?这里就最近 ...

  4. Win10 开始运行不保存历史记录原因和解决方法

    Win10 开始运行命令以后,再次打开就没有任何历史记录了,常规方法是桌面-右键-个性化-开始-显示最常用的应用..可是打开是灰色的不可选. 每次打开开始都没有以前的记录..比如需要打开下regedi ...

  5. 【EXE报错】win10运行C#程序保存报错:HTTP 无法注册URL ,进程不具有此命名空间的访问权限

    在win10系统运行C#程序出现以下报错 异常信息 [1]异常信息:HTTP 无法注册 URL http://+:13000/Core/Real/HandheldService/.进程不具有此命名空间 ...

  6. Win10 for Phone 裁剪控件

    <Page.BottomAppBar> <CommandBar x:Name="appBar"> <AppBarButton Label=" ...

  7. win10 sshsecureshellclient删除profile保存的信息

    C:\Users\joe\AppData\Roaming\SSH

  8. matlab载入图像,旋转,裁剪 保存

    clc;clear all;close all src=imread('C:\Users\think\Desktop\12.jpg'); subplot(,,) imshow(src); I = ma ...

  9. Win10修改编辑hosts文件无法保存怎么办

    Win10无法修改编辑保存hosts文件怎么办?Win10系统默认是没有权限去编辑保存系统里的文件,这也是权限不够才导致修改编辑hosts后无法保存的原因,解决的办法就是把自己的帐户权限给提高就行了. ...

随机推荐

  1. PyQt4多线程定时刷新控件

    1.通过事件关联和线程关联的方法刷新控件 self.listview=updatelistview()self.listview.updateText.connect(self.viewlist)   ...

  2. cf219d

    树形dp #include <cstdio> #include <vector> using namespace std; #define D(x) const int INF ...

  3. 解读Unity中的CG编写Shader系列二

    转自 http://www.itnose.net/detail/6095974.html 上一篇文章的例子中我们可以看到顶点着色器的输出参数可以说是直接作为了片段着色器的形参传递过来,那么不由得一个问 ...

  4. Html5 postMessage

    解释: 跨文档消息传输Cross Document Messaging. 编写代码前注意判断浏览器是否支持Html5 实例: b页面向a页面发送消息. <!DOCTYPE> <htm ...

  5. locustio压力测试

    2015年7月17日 22:19:17 星期五 这里记录下学习道路, 防止忘了 操作系统是centos: 首先是linux系统, 装有Python 和 Python-devel (否则安装软件会提示p ...

  6. 修改MySQL中字段的类型和长度

    MySQL修改字段类型的命令是: mysql> alter table 表名 modify column 字段名 类型; 假设在MySQL中有一个表为:address,有一个字段为city 初始 ...

  7. Delphi XE5 常见问题解答

    Delphi XE5 常见问题解答 有关于新即时试用的问题吗?请看看 RAD Studio 即时试用常见问答. 常见问题 什么是 Delphi? Embarcadero? Delphi? XE5 是易 ...

  8. Effective C++ -----条款25:考虑写出一个不抛异常的swap函数

    当std::swap对你的类型效率不高时,提供一个swap成员函数,并确定这个函数不抛出异常. 如果你提供一个member swap,也该提供一个non-member swap用来调用前者.对于cla ...

  9. Effective C++ -----条款07:为多态基类声明virtual析构函数

    polymorphic(带多态性质的)base classes应该声明一个virtual析构函数.如果class带有任何virtual函数,它就应该拥有一个virtual析构函数. Classes的设 ...

  10. HDU 4873 ZCC Loves Intersection(JAVA、大数、推公式)

    在一个D维空间,只有整点,点的每个维度的值是0~n-1 .现每秒生成D条线段,第i条线段与第i维度的轴平行.问D条线段的相交期望. 生成线段[a1,a2]的方法(假设该线段为第i条,即与第i维度的轴平 ...