本文整理汇总了C#中System.Windows.Media.Imaging.BitmapSource.SetSource方法的典型用法代码示例。如果您正苦于以下问题:C# BitmapSource.SetSource方法的具体用法?C# BitmapSource.SetSource怎么用?C# BitmapSource.SetSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.BitmapSource
的用法示例。
在下文中一共展示了BitmapSource.SetSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetImageSource
private void SetImageSource(string imageKey, BitmapSource imageSource, Stream imageDataStream)
{
if (imageSource == null)
{
throw new ArgumentNullException("imageSource");
}
try
{
imageSource.SetSource(imageDataStream);
}
catch (Exception)
{
DeleteImageFromCache(imageKey);
DeleteImageFromMemoryCache(imageKey);
}
}
示例2: DisposeImage
/// <summary>
/// Util: Dispose a bitmap resource
/// </summary>
/// <param name="image">BitmapSource subclass to dispose</param>
private void DisposeImage(BitmapSource image)
{
if (image != null)
{
try
{
using (var ms = new MemoryStream(new byte[] { 0x0 }))
{
image.SetSource(ms);
}
}
catch (Exception)
{
}
}
}
示例3: photoChooser_Completed
void photoChooser_Completed(object sender, PhotoResult e)
{
if (e.Error != null || e.ChosenPhoto == null)//没有选择图片则返回跳出该方法
{
return;
}
//创建BitmapImage来存储选择器的图片
if (IsFromPhoto == false)
{
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(e.ChosenPhoto);
Image imgBase = new Image();
imgBase.Source = bitmapImage;
WriteableBitmap writeableBitmap = new WriteableBitmap(480, 600);
ScaleTransform scale = new ScaleTransform();
scale.ScaleX = 480.0 / bitmapImage.PixelHeight;
scale.ScaleY = 640.0 / bitmapImage.PixelWidth;
RotateTransform rotate = new RotateTransform();
rotate.Angle = 90;
//rotate.CenterX = 4.0 / 2;
//rotate.CenterY = 640.0 / 2;
TranslateTransform translate = new TranslateTransform();
translate.X = 480;
//translate.Y = -60;
TransformGroup transGroup = new TransformGroup();
transGroup.Children.Add(scale);
transGroup.Children.Add(rotate);
transGroup.Children.Add(translate);
writeableBitmap.Render(imgBase, transGroup);//在位图中呈现元素
writeableBitmap.Invalidate();
bitmapSource = writeableBitmap;
}
else
{
bitmapSource = new BitmapImage();
bitmapSource.SetSource(e.ChosenPhoto);
}
// this.NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
Dispatcher.BeginInvoke(() =>
{
NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));
});
}