- 浏览: 426241 次
- 性别:
- 来自: 唐山
文章分类
最新评论
-
hautbbs:
谢谢分享!
ASP.NET 导出Excel 和csv -
hautbbs:
感谢分享!
ASP.NET 导出Excel乱码的终极解决 -
wyf:
zcl920 写道只能说 看不懂。要发就发全 取一段出来 有什 ...
图片上绘制文字换行处理 -
zcl920:
只能说 看不懂。要发就发全 取一段出来 有什么用。
图片上绘制文字换行处理 -
380086154:
有用,谢谢。
js比较日期
One of the high-profile missing features in Silverlight has been Printing support. If you have ever tried to print a web page containing Silverlight content, what you saw on the printed page may be skewed or even missing altogether! So, what if you wanted to print a portion of your Silverlight screen, or take a “snapshot” image of the Silverlight UI to include in a report or other printable format?
WriteableBitmap bitmap = new WriteableBitmap(cnvSource, new TranslateTransform());2.Convert the WriteableBitmap pixels to a PNG using Joe Stegman's PNG encoder.
EditableImage imageData = new EditableImage(bitmap.PixelWidth, bitmap.PixelHeight); for (int y = 0; y < bitmap.PixelHeight; ++y) { for (int x = 0; x < bitmap.PixelWidth; ++x) { int pixel = bitmap.Pixels[bitmap.PixelWidth * y + x]; imageData.SetPixel(x, y, (byte)((pixel >> 16) & 0xFF), (byte)((pixel >> 8) & 0xFF), (byte)(pixel & 0xFF), (byte)((pixel >> 24) & 0xFF) ); } } Stream pngStream = imageData.GetStream();NOTE that this PNG encoder does NOT include compression! This would be a good optimization to add, but also note that the GZipStream class is not present in Silverlight, so you would need to use an outside compression library such as SharpZipLib.
3.At this point, we have the PNG bytes in a stream, and you could take several approaches to get these bytes up to the server – such as using an Http Handler (ASHX). In this demo, we’ll place the bytes into a hidden field on the ASPX page and post the page back to the server for inclusion in a report. To do this, we’ll translate the PNG bytes into a string using Base64 encoding:
4.Now that we have our bytes up on the server, we can decode them and feed them to a ReportViewer (RDLC) report. This will give us a nicely printed format and the ability to export to PDF: That’s it! I really think this use of WriteableBitmap as a snapshot/print function will be useful in some of my projects that need to capture the current view of the Silverlight application. byte[] binaryData = new Byte[pngStream.Length];
long bytesRead = pngStream.Read(binaryData, 0, (int)pngStream.Length);
string base64String =
System.Convert.ToBase64String(binaryData,
0,
binaryData.Length);
// save the encoded PNG bytes to the page
HtmlDocument document = HtmlPage.Document;
HtmlElement txtPNGBytes = document.GetElementById("txtPNGBytes");
txtPNGBytes.SetProperty("value", base64String);
// this calls a js function "postBackPrint" which will cause a postback
HtmlPage.Window.CreateInstance("postBackPrint", new string[] { });
string bytes64 = Request["txtPNGBytes"];
byte[] imageBytes = System.Convert.FromBase64String(bytes64);
DSReportPrintImage ds = new DSReportPrintImage();
DataRow drImage = ds.Tables[0].NewRow();
drImage["ImageBytes"] = imageBytes;
ds.Tables[0].Rows.Add(drImage);
ReportViewer1.LocalReport.ReportPath = "ReportPrintSilverlight.rdlc";
ReportDataSource src = new ReportDataSource("DSReportPrintImage_ImageData", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(src);
ReportViewer1.LocalReport.Refresh();
- 1_13085732.zip (395.7 KB)
- 下载次数: 6
发表评论
-
Silverlight同步(Synchronous)调用WCF服务
2015-04-10 15:51 757基于AutoResetEvent的同步实现 利用Aut ... -
iis8 默认不支持svc解决方法
2014-09-18 18:57 731以下内容对于使用WIN2012 部署V9的时候使用。 ... -
WCF-IErrorHandler
2011-10-11 16:30 1010使用 IErrorHandler 接口,我们可以更深入地 ... -
Silverlight自定义类库实现应用程序缓存
2011-09-25 14:06 908默认情况下,如果SL项目引用了一些其它程序集(即通俗意义上的d ... -
附加属性指定图片地址
2010-12-09 16:58 999public static void SetUrlSource ... -
Silverlight 中读取JSON数据
2010-12-02 09:16 1301假定按照 如何:对基于 ... -
画雷达图背景
2010-10-09 16:36 1316直接糊代码 public partial class Mai ... -
拖动类
2010-08-03 15:51 666public static class DragDrop { ... -
显示数据库图片
2010-05-07 10:57 1136可以创建一个类,该类允许通过从 IValueConverter ... -
Convert Hex String to .NET Color(十六进制字符串颜色转Color)
2010-05-04 17:49 2205string xCol = "#FF00DD&quo ... -
ASP.NET Membership and Roles in Silverlight 3
2010-04-27 11:02 1264Since Silverlight applications ... -
独立存储应用Using Isolated
2010-04-27 10:43 1022Silverlight uses Isolated Stora ... -
Silverlight客户端和WCF服务器端共享类库
2010-04-15 12:42 2257WCF为了给Silverlight客户端提供引用共享类型,我们 ... -
Silverlight实现多语言
2010-03-08 15:11 1811首先添加一个主资源文件Text.resx 设置生成代码 pub ... -
动态载入xap文件
2010-02-25 11:10 1140myButton.Click += new RoutedEve ... -
SilverLight中调用自定义用户控件
2010-02-25 11:07 20751.在aspx页面中切换调用同一个SilverLight项目中 ... -
Silverlight拖放封装
2009-12-09 10:51 1517public static class ExtendMe ... -
Silverlight图表控件 (超炫)
2009-12-03 14:43 7082开源的项目visifire,使用它可以在Silverlig ...
相关推荐
但如果有时候不想依赖D3D时,还有一种方案实现视频的渲染,使用wpf的WriteableBitmap,WriteableBitmap的祖先接口有ImageSource,即可以作为Image的Source显示画面。我们只需往WriteableBitmap中写入图像数据即可...
用WriteableBitmap绑定Image控件数据源,提高视频处理效率,减轻CPU压力
WPF使用 WriteableBitmap 类基于每个框架来更新和呈现位图。这对于生成算法内容(如分形图像)和数据可视化(如音乐可视化工具)很有用
这是一个在WPF下的绘图功能代码,能过写位图,实现顶级的绘图性能,多线程架构,项目代码完整,可直接运行。可以修改适用于自定义控件。
Silverlight缩略图 图片压缩 WriteableBitmap wimg = this.RenderThumbnail(bmap);
WPF 基础视频教程(共50集)---38.WriteableBitmap类
WriteableBitmap 类可用于所有 XAML 风格,包括 WPF、Windows 10 UWP、Windows Phone、WinRT Windows Store XAML 和 Silverlight。 它支持 .NET Framework 和 .NET Core 3,甚至被移植到 。 WriteableBitmapEx 允许...
本技巧将恢复我们在开发过程中所需的大多数转换类型
私有 WPF 构建版本 当前的 WPF 在 [https://github.com/dotnet/wpf](https://github.com/dotnet/wpf) 完全开源,使用友好的 MIT 协议,意味着允许任何人任何组织和企业任意处置,包括使用,复制,修改,合并,发表,...
直接调用库对人脸识别,很好的解决了我们对人脸的捕捉的问题
抓取摄像机视频流一帧的YUV数据,转RGB转bitmap图的类,从现项目中剥离的,保证能用 。
SharpPdf417 介绍 SharpPdf417 是一个便携式库,可让您创建原始 PDF 417 条码。 代码在 MIT/X11 下发布,所以请随时修改并与... 在 Xaml 中,您可以使用 WriteableBitmap 直接设置像素 安装 您可以通过安装库: 安装包
提供一些常用的功能,比如WriteableBitmap到BitmapImage转换等
WPF工程 可绘制多个矩形 绘制结束后可拖动矩形的四个角 动态改变矩形大小
在unity3d里面把Bitmap格式转为Texture2D的格式,使用C#语言
WPF高性能绘图的方法,使用WriteableBitmap对象,介绍使用GDI+绘制图形和操作像素的两种方法。
this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height,96.0,96.0, PixelFormats.Bgr32,null); bodies = new Body[6]; msfr = KinectSensor....
第1章 WPF概述 3 1.1 Windows图形演化 3 1.1.1 DirectX:新的图形引擎 4 1.1.2 硬件加速与WPF 4 1.2 WPF:高级API 4 1.3 分辨率无关性 5 1.3.1 WPF单位 6 1.3.2 系统DPI 7 1.3.3 位图和矢量图形 9 1.4 WPF体系结构 ...
第1章 WPF概述 3 1.1 Windows图形演化 3 1.1.1 DirectX:新的图形引擎 4 1.1.2 硬件加速与WPF 4 1.2 WPF:高级API 4 1.3 分辨率无关性 5 1.3.1 WPF单位 6 1.3.2 系统DPI 7 1.3.3 位图和矢量图形 9 1.4 WPF体系结构 ...
您可以使用WebPImage.DecodeFromByteArray方法直接从静态WEBP获取WriteableBitmap 。 如果要解码动画的WEBP(或同时解码两者),则可以改用WebPImage.CreateFromByteArray 。 此方法返回对WebPImage对象实例的引用...