Tag: writeablebitmap

WriteableBitmap内存泄漏?

我正在使用下面的代码创建一个基于UI元素的实时图块。 它在WriteableBitmap上呈现uiElement ,保存位图+返回文件名。 此方法在Windows Phone后台任务代理中运行,我正在运行内存限制。 private string CreateLiveTileImage(Canvas uiElement, int width, int heigth) { var wbmp = new WriteableBitmap(width, heigth); try { wbmp.Render(uiElement, null); wbmp.Invalidate(); var tileImageName = _liveTileStoreLocation; using (var stream = new IsolatedStorageFileStream(tileImageName, FileMode.Create, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication())) { wbmp.SaveJpeg(stream, width, heigth, 0, 100); stream.Close(); } uiElement = null; wbmp = null; GC.Collect(); return “isostore:” […]

从menuitem更新WPF窗口图像,但在while循环中更新

好的,这是一个真正令人头疼的问题: 如果我选择一个导致图像的菜单项,构成整个窗口(一个writeableBitmap)以在其上绘制一些像素,它就会这样做并正确显示。 但是,如果我向同一个方法添加一个while循环(假设为5个循环),则位图上的绘图不会显示,直到循环完成,然后正确显示第5个重绘位图。 那么,当选择了一个菜单项但是在while循环中被跳过时,窗口中是否会出现某种“自动刷新”? 更多细节。 这很好用(带来一个’干净’的图像,在它上面绘制一些东西,显示它): // This brings in a ‘clean’ image writeableBitmap = new WriteableBitmap(CleanVegMap); image.Source = writeableBitmap; // This makes a bunch of draws on the bitmap DrawDinos2d(); 然而,这会“消失”10秒,然后只显示最后一个(即第5个)图像: int z = 0; while (z < 5){ z++; // This brings in a 'clean' image writeableBitmap = new WriteableBitmap(CleanVegMap); image.Source = writeableBitmap; […]

使用WPF将WriteableBitmap保存到文件

我有: WriteableBitmap bmp; 我基本上想将它保存到磁盘上的文件中,如下所示: C:\bmp.png 我读了一些提到阅读的论坛: bmp.Pixels 然后将这些像素保存到Bitmap然后使用Bitmap.SaveImage()函数。 但是,我无法访问任何Pixels 。 我的WriteableBitmap显然没有任何名为Pixels属性。 我使用.NET Framework 4.0。

如何将WriteableBitmap转换为BitmapImage?

BitmapImage bitmapImage = new BitmapImage(new Uri(“arka_projects_as_logo.png”, UriKind.Relative)); Image uiElement = new Image() { Source = bitmapImage }; ScaleTransform t = new ScaleTransform() { ScaleX = 0.2, ScaleY = 0.2 }; WriteableBitmap writeableBitmap = new WriteableBitmap(uiElement,t); 我想将此转换的结果(writeableBitmap)插入到System.Windows.Controls.Image中。 我这样做的时候: Image arkaImage = new Image() { Source = writeableBitmap }; arkaImage根本没有显示。 有什么办法可以让它发挥作用?

在C#中将WriteableBitmap转换为位图

有没有办法在C#中将WriteableBitmap转换为Bitmap ?

如何在Windows Phone 7中的后台线程上的WriteableBitmap上呈现文本?

我试图在Windows Phone 7应用程序中的位图上呈现文本。 看起来或多或少类似于以下的代码在主线程上运行时可以正常工作: public ImageSource RenderText(string text, double x, double y) { var canvas = new Canvas(); var textBlock = new TextBlock { Text = text }; canvas.Children.Add(textBloxk); Canvas.SetLeft(textBlock, x); Canvas.SetTop(textBlock, y); var bitmap = new WriteableBitmap(400, 400); bitmap.Render(canvas, null); bitmap.Invalidate(); return bitmap; } 现在,由于我必须使用更复杂的东西渲染多个图像,我想在后台线程上渲染位图以避免无响应的UI。 当我使用BackgroundWorker执行此操作时, TextBlock的构造函数会抛出一个UnauthorizedAccessException声称这是一个无效的跨线程访问。 我的问题是:如何在不阻塞UI的情况下在位图上呈现文本? 请不要建议使用Web服务进行渲染。 我需要渲染大量图像,并且带宽成本不能满足我的需求,离线工作的能力是一项主要要求。 如果有另一种呈现文本的方法,解决方案不一定必须使用WriteableBitmap或UIElements 。 编辑 另一个想法:有没有人知道是否应该可以在另一个线程中运行UI消息循环,然后让该线程完成工作? […]

编辑WriteableBitmap的原始像素数据?

是否可以直接读/写WriteableBitmap的像素数据? 我目前正在使用WriteableBitmapEx的SetPixel()但它很慢,我想直接访问像素而没有任何开销。 我有一段时间没有使用过HTML5的canvas,但是如果我没记错的话,你可以将它的图像数据作为单个数字数组获得,这就是我正在寻找的东西 提前致谢