本文整理汇总了C#中System.Windows.Controls.Image类的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Controls.Image类的具体用法?C# System.Windows.Controls.Image怎么用?C# System.Windows.Controls.Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Windows.Controls.Image类属于命名空间,在下文中一共展示了System.Windows.Controls.Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeGridTile
// Deserializes a serialized grid tile, making it fit for use in our editor grid.
public GridTile DeserializeGridTile(GridTileSerializable tile)
{
if (tile.Image == null) return null;
try
{
// Effectively creating an image out of the byte array in the serialized grid tile.
Image myImage = new Image();
using (MemoryStream stream = new MemoryStream(tile.Image))
{
PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
BitmapSource bitmapSource = decoder.Frames[0];
myImage.Source = bitmapSource;
}
return new GridTile(tile.Rotation, tile.Id, myImage, tile.CollisionMap)
{
Row = tile.Row,
Column = tile.Column,
CollisionMap = tile.CollisionMap
};
}
catch (Exception ex)
{
Console.WriteLine(ex);
return null;
}
}
示例2: GetWpfCompatibleImage
public static Image GetWpfCompatibleImage(System.Drawing.Image image, int newWidth = -1, int maxHeight = -1, string cachedName = null)
{
Image result = null;
string uriPath;
var filePath = GetImageFilePath(cachedName, out uriPath);
try
{
if (image != null)
{
if (!File.Exists(filePath))
{
var img = newWidth > 0
? Shared.Utility.ResizeImage(image, newWidth, maxHeight)
: image;
img.Save(filePath, ImageFormat.Png);
}
result = new Image { Source = new BitmapImage(new Uri(filePath)) };
}
}
catch (Exception e)
{
Logger.TraceErr(MethodBase.GetCurrentMethod(), e);
}
return result;
}
示例3: Chooser_Load
private void Chooser_Load(object sender, EventArgs e)
{
//label2.Text = CardName;
Guid card = Guid.Empty;
string[] list = new string[SetList.Count];
int i = 0;
foreach (CardModel Card in SetList)
{
Set CardSet = Card.Set;
list[i] = CardSet.Name;
i++;
}
List<string> unique = new List<string>();
unique.AddRange(list.Distinct());
comboChooser.Sorted = true;
foreach (string setname in unique) { comboChooser.Items.Add(setname); }
comboChooser.Text = comboChooser.Items[0].ToString();
// Default Image
GamesRepository proxy = new GamesRepository();
Game mygame = proxy.Games[GameIndex];
card = SetList[0].Id;
label2.Text = SetList[0].Name;
BitmapImage img = new BitmapImage();
System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
selectedCard = card;
}
示例4: ViewCursor
private static void ViewCursor(Image img, string source)
{
var cursor = GetCursor(source);
if (cursor == null)
{
return;
}
using (var bmp = new Bitmap(cursor.Size.Width, cursor.Size.Height))
{
using (var g = Graphics.FromImage(bmp))
{
var drawingRect = new Rectangle(0, 0, cursor.Size.Width, cursor.Size.Height);
g.FillRectangle(Brushes.White, drawingRect);
cursor.Draw(g, drawingRect);
}
var ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
var bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();
img.Source = bi;
}
}
示例5: VideoStreamDisplay
public VideoStreamDisplay(System.Windows.Controls.Image img, int rotationAngle, Uri streamUri)
{
_dispImage = img;
_rotationAngle = rotationAngle;
_streamUri = streamUri;
_decoder.FrameReady += handleFrameFn;
}
示例6: Radar
private int _refresherY; //HAND coordinate
#endregion Fields
#region Constructors
public Radar(Image imageBox)
{
ImageBox = imageBox;
_bitmapWidth = (int)imageBox.Width;
_bitmapHeight = (int)imageBox.Height;
_offset = (_bitmapWidth - Constans.RADAR_WIDTH) / 2;
//create Bitmap
Bmp = new Bitmap(_bitmapHeight, _bitmapWidth);
//center
_centerX = (int)imageBox.Height / 2;
_centerY = (int)imageBox.Width / 2;
//initial degree of HAND
_currentDegree = 0;
//timer
_timer.Interval = 1; //in millisecond
_timer.Tick += ReloadRadar;
_landscape = LandscapeProvider.CreateLandscape();
//Draw start position of radar
ReloadRadar(null, null);
}
示例7: ProcessInfo
public ProcessInfo(string processName, int processId, string processPath, Image processIcon)
{
ProcessName = processName;
ProcessPath = processPath;
ProcessId = processId;
ProcessIcon = processIcon;
}
示例8: AddPicture
/// <summary>
/// Adds the picture to the rich textbox.
/// </summary>
/// <param name="imagelocation">The imagelocation.</param>
private void AddPicture(string imagelocation)
{
var bitmap = new BitmapImage(new Uri(imagelocation));
var image = new Image {Source = bitmap, Width = 35};
var uiContainer = new InlineUIContainer(image);
var tp = txtMessageToSend.CaretPosition;
if (tp.Paragraph != null) tp.Paragraph.Inlines.Add(uiContainer);
}
示例9: InitializeWebCam
public void InitializeWebCam(ref System.Windows.Controls.Image ImageControl)
{
webcam = new WebCamCapture();
webcam.FrameNumber = ((ulong)(0ul));
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;
}
示例10: PrintPage
private static UIElement PrintPage(BitmapSource bitmap)
{
var bitmapSize = new System.Windows.Size(bitmap.PixelWidth, bitmap.PixelHeight);
var image = new System.Windows.Controls.Image { Source = bitmap };
image.Measure(bitmapSize);
image.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), bitmapSize));
return image;
}
示例11: WebCamWindow
public WebCamWindow(string applicationName)
{
InitializeComponent();
_webCam = new WebCamCapture { FrameNumber = ((0ul)), TimeToCapture_milliseconds = FrameNumber };
_webCam.ImageCaptured += webCam_ImageCaptured;
_frameImage = SourceImage;
_applicationName = applicationName;
}
示例12: convertDrawingImageToWPFImage
private System.Windows.Media.ImageSource convertDrawingImageToWPFImage(System.Drawing.Image gdiImg)
{
System.Windows.Controls.Image img = new System.Windows.Controls.Image();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(gdiImg);
IntPtr hBitmap = bmp.GetHbitmap();
return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
示例13: PrintImage
internal void PrintImage()
{
PrintImage pi = new PrintImage();
System.Windows.Controls.Image pImage = new System.Windows.Controls.Image();
pImage.Source = ImageCtrl.Source;
pi.Print(pImage);
}
示例14: ToWPFImage
/// <summary>
/// Convert the icon in a WPF-Image
/// </summary>
/// <param name="icon"></param>
/// <param name="width">Width of new Image</param>
/// <param name="height">Height of new Image</param>
/// <returns>WPF-Image-Control</returns>
public static System.Windows.Controls.Image ToWPFImage(this Icon icon, int width, int height)
{
System.Windows.Controls.Image img = new System.Windows.Controls.Image();
img.Width = width;
img.Height = height;
img.Source = icon.ToBitmapSource();
return img;
}
示例15: GetImageFromWeb
/// <summary>
/// Gets the image from web.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>System.Windows.Controls.Image.</returns>
private System.Windows.Controls.Image GetImageFromWeb(string url)
{
var image = new System.Windows.Controls.Image();
var uri = new Uri(url, UriKind.Absolute);
image.Source = new BitmapImage(uri);
return image;
}