Win10 for Phone 裁剪保存
//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 裁剪保存的更多相关文章
- Win10 hosts文件无法保存
Win10无法修改编辑保存hosts文件怎么办?Win10系统默认是没有权限去编辑保存系统里的文件,这也是权限不够才导致修改编辑hosts后无法保存的原因,解决的办法就是把自己的帐户权限给提高就行了. ...
- mono for android 获取手机照片或拍照并裁剪保存
axml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...
- Win10注册表无法保存对权限所作的更改拒绝访问
在对系统的安全控制得越来越多的情况下,要对注册表的关键数据进行修改是件挺麻烦的事,时不时会弹出无法保存对xxxxxx权限所作的更改,拒绝访问,操作产生错误,操作出现错误的提示,这时怎么办呢?这里就最近 ...
- Win10 开始运行不保存历史记录原因和解决方法
Win10 开始运行命令以后,再次打开就没有任何历史记录了,常规方法是桌面-右键-个性化-开始-显示最常用的应用..可是打开是灰色的不可选. 每次打开开始都没有以前的记录..比如需要打开下regedi ...
- 【EXE报错】win10运行C#程序保存报错:HTTP 无法注册URL ,进程不具有此命名空间的访问权限
在win10系统运行C#程序出现以下报错 异常信息 [1]异常信息:HTTP 无法注册 URL http://+:13000/Core/Real/HandheldService/.进程不具有此命名空间 ...
- Win10 for Phone 裁剪控件
<Page.BottomAppBar> <CommandBar x:Name="appBar"> <AppBarButton Label=" ...
- win10 sshsecureshellclient删除profile保存的信息
C:\Users\joe\AppData\Roaming\SSH
- matlab载入图像,旋转,裁剪 保存
clc;clear all;close all src=imread('C:\Users\think\Desktop\12.jpg'); subplot(,,) imshow(src); I = ma ...
- Win10修改编辑hosts文件无法保存怎么办
Win10无法修改编辑保存hosts文件怎么办?Win10系统默认是没有权限去编辑保存系统里的文件,这也是权限不够才导致修改编辑hosts后无法保存的原因,解决的办法就是把自己的帐户权限给提高就行了. ...
随机推荐
- 认识Visual Studio 条件编译
一开始是在一些源代码中看到这些语法符号,了解到这就是" 条件编译"技术
- WPF 中更新界面信息
1.Dispatcher.BeginInvoke int ii = 0; new Thread(new ParameterizedThreadStart((i) => { while (true ...
- 【leetcode】Scramble String
Scramble String Given a string s1, we may represent it as a binary tree by partitioning it to two no ...
- sql语句操作
1.1 SQL语句 1.1.1 什么是SQL SQL:Structured Query Language, 结构化查询语言. 特点: * 非过程性语言: * 过程性语言特点:一个语句需要依赖上面的几条 ...
- uniq 重复行统计
uniq 命令 文字 uniq 是LINUX命令 用途 报告或删除文件中重复的行. 语法 uniq [ -c | -d | -u ] [ -f Fields ] [ -s Characters ] ...
- XE 的程序升级 XE5 问题处理记录
XE 的程序升级 XE5 问题处理记录 1. [dcc32 Fatal Error] frxClass.pas(3556): F1026 File not found: 'xxxxx\Registr ...
- h5页面的公共css
/*reset*/body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,tex ...
- Maven 3.3.3 Win10环境下的使用实例(中)
继上一篇文章介绍了Maven在Windows中的安装,本文将介绍 Maven 的核心概念. POM (Project Object Model) Maven 插件 Maven 生命周期 Maven 依 ...
- a byte of python (摘01)
a byte of python 第一章 介绍 Python 特色 简单.易学.免费.开源 高层语言.可移植性.解释性 面向对象.可扩展性.可嵌入性 丰富的库 第二章 安装Python http:// ...
- hiho一下第二周 Trie树
题目链接:http://hihocoder.com/problemset/problem/1014 #include <iostream> #include <cstdio> ...