草庐IT

BitmapImage1

全部标签

c# - 无法将类型为 'MS.Internal.NamedObject' 的对象转换为 BitmapImage

我正在构建一个WPF应用程序,但在其中出现错误Unabletocastobjectoftype'MS.Internal.NamedObject'totype'System.Windows.Media.Imaging.BitmapImage'XAML代码:C#转换器代码:publicclassImageConverter:IMultiValueConverter{publicobjectConvert(object[]values,TypetargetType,objectparameter,System.Globalization.CultureInfoculture){boolisC

c# - 使用 InkCanvas 中的笔触裁剪 BitmapImage

我的任务是创建一个“Cinemagraph”功能,用户必须使用InkCanvas选择所需的区域来绘制选定的像素,这些像素在其余的动画/视频中应该保持不变(或者,选择应该“活着”的像素)。示例:我正在考虑从InkCanvas中获取Stroke集合,并使用它来裁剪图像并与未触及的图像合并。我该怎么做?我可以轻松地从磁盘加载图像,但如何根据笔画裁剪图像?更多详情:绘制并选择应保持静态的像素后,我有一个Stroke集合。我可以获得每个单独的Stroke的Geometry,但我可能需要合并所有几何图形。基于合并的Geometry,我需要反转(Geometry)并用于剪辑我的第一帧,稍后准备好剪辑

c# - 如何将 WriteableBitmap 转换为 BitmapImage?

BitmapImagebitmapImage=newBitmapImage(newUri("arka_projects_as_logo.png",UriKind.Relative));ImageuiElement=newImage(){Source=bitmapImage};ScaleTransformt=newScaleTransform(){ScaleX=0.2,ScaleY=0.2};WriteableBitmapwriteableBitmap=newWriteableBitmap(uiElement,t);我想将此转换的结果(writeableBitmap)插入到System.

c# - 使用 WPF 在 C# 中异步加载 BitmapImage

使用WPF在C#中异步加载BitmapImage的最佳方法是什么? 最佳答案 我只是在研究这个,不得不投入我的两分钱,虽然在最初的帖子发布几年后(以防万一其他人来寻找我正在研究的同样的东西)。我有一个Image控件,需要使用Stream在后台加载它的图像,然后显示。我一直遇到的问题是BitmapSource、Stream源和Image控件都必须位于同一位置线程。在这种情况下,使用Binding并将其设置为IsAsynch=true将引发跨线程异常。BackgroundWorker非常适合WinForms,您可以在WPF中使用它,但我

C#加载JPG文件,提取BitmapImage

我正在尝试从JPG中提取BitmapImage。这是我的代码:FileStreamfIn=newFileStream(sourceFileName,FileMode.Open);//sourceJPGBitmapdImg=newBitmap(fIn);MemoryStreamms=newMemoryStream();dImg.Save(ms,ImageFormat.Jpeg);image=newBitmapImage();image.BeginInit();image.StreamSource=newMemoryStream(ms.ToArray());image.EndInit();

c# - 将 BitmapImage 转换为字节数组

我想在WindowsPhone7应用程序中将BitmapImage转换为ByteArray。所以我尝试了这个但是它抛出了运行时异常“无效指针异常”。任何人都可以解释为什么我正在尝试做的事情会引发异常。你能为此提供替代解决方案吗?publicstaticbyte[]ConvertToBytes(thisBitmapImagebitmapImage){byte[]data;//GetanImageStreamusing(MemoryStreamms=newMemoryStream()){WriteableBitmapbtmMap=newWriteableBitmap(bitmapImage

c# - 将 Resources.resx 中的 BitmapImage 分配给 Image.Source?

我想将我的Resources.resx中的BitmapImage分配给Image。事先我将.png图像保存到Resources.resx。此图像现在位于“/Resources/logo.png”中。在阅读了几篇SO帖子和其他文章后,我现在有了这个:logoImage.Source=newBitmapImage(newUri(@"pack://application:,,,/Resources/logo.png"));不幸的是,它不起作用。我不知道如何解决这个问题。我尝试用完整路径替换Pack-URI并且它有效,但我想使用相对路径以便在绝对路径不正确的不同机器上使用相同的源.谁能帮我解决

C# Windows 8 Store (Metro, WinRT) 字节数组到 BitmapImage

我正在开发一个将滤镜应用于图像的Windows8Metro应用程序。我有该应用程序的Web版本并想移植它。但众所周知,WinRT并不具备.NET提供的所有优点:/目前我正在字节数组上应用过滤器,我想保持这种状态,因为它非常快!因此,在过去的几天里,我一直在寻找将StorageFile转换为byte[],然后将byte[]转换为BitmapImage的方法。到目前为止,我已经设法完成了第一个(StorageFile到byte[])。这是我的做法:publicasyncTaskImageFileToByteArray(StorageFilefile){IRandomAccessStream

c# - 如何将 Byte[] 转换为 BitmapImage

我需要帮助,我有这个方法可以从Byte[]获取BitmapImagepublicBitmapSourceByteToBitmapSource(byte[]image){BitmapImageimageSource=newBitmapImage();using(MemoryStreamstream=newMemoryStream(image)){stream.Seek(0,SeekOrigin.Begin);imageSource.BeginInit();imageSource.StreamSource=stream;imageSource.CacheOption=BitmapCache

c# - 将 BitmapImage 保存到文件

我正在开发一个程序,可以将图像从URL下载到位图图像并显示它。接下来,我尝试使用jpegbitmapencoder将位图图像保存到硬盘。文件已成功创建,但实际jpeg图像为空或1个黑色像素。publicGuidSavePhoto(stringistrImagePath){ImagePath=istrImagePath;BitmapImageobjImage=newBitmapImage(newUri(istrImagePath,UriKind.RelativeOrAbsolute));PictureDisplayed.Source=objImage;savedCreationObjec