本文整理汇总了C#中System.Windows.Media.Imaging.BitmapImage类的典型用法代码示例。如果您正苦于以下问题:C# BitmapImage类的具体用法?C# BitmapImage怎么用?C# BitmapImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapImage类属于System.Windows.Media.Imaging命名空间,在下文中一共展示了BitmapImage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public Model3DGroup Create(Color modelColor,string pictureName, Point3D startPos, double maxHigh)
{
try
{
Uri inpuri = new Uri(@pictureName, UriKind.Relative);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = inpuri;
bi.EndInit();
ImageBrush imagebrush = new ImageBrush(bi);
imagebrush.Opacity = 100;
imagebrush.Freeze();
Point[] ptexture0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) };
Point[] ptexture1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) };
SolidColorBrush modelbrush = new SolidColorBrush(modelColor);
Model3DGroup cube = new Model3DGroup();
Point3D uppercircle = startPos;
modelbrush.Freeze();
uppercircle.Y = startPos.Y + maxHigh;
cube.Children.Add(CreateEllipse2D(modelbrush, uppercircle, _EllipseHigh, new Vector3D(0, 1, 0)));
cube.Children.Add(CreateEllipse2D(modelbrush, startPos, _EllipseHigh, new Vector3D(0, -1, 0)));
cube.Children.Add(CreateEllipse3D(imagebrush, startPos, _EllipseHigh, maxHigh, ptexture0));
return cube;
}
catch (Exception ex)
{
throw ex;
}
}
开发者ID:kse-jp,项目名称:RM-3000,代码行数:31,代码来源:EllipseModel.cs
示例2: Init
private void Init(String n, bool s)
{
Name = n;
Male = s;
JobRole = "Boss";
pictureFile = ".../.../Pictures/Enemies/Ravenscroft.png";
characterPicture = new BitmapImage(new Uri(pictureFile, UriKind.Relative));
/******************************************************************
* stat progression unique to this job role.
* ****************************************************************
*/
HealthMulti = 3.00;
EnergyMulti = 3.00;
AttackMulti = 2.00;
DefenseMulti = 3.00;
SpeedMulti = 2;
AgilityMulti = 2;
AttackRangeMulti = 1.00;
SpecialAttackMulti = 3.00;
SpecialDefenseMulti = 3.00;
ExperienceAmountMulti = 100.00;
/******************************************************************
* stats initialized after multipliers applied.
* ****************************************************************
*/
InstantiateLevel(1);
}
开发者ID:insonia78,项目名称:project,代码行数:31,代码来源:Boss.cs
示例3: using
void IThumbnailManager.SetThumbnail(string name, BitmapImage thumbnail)
{
using (var zipArchive = new ZipArchive("AssetThumbnails.zip"))
{
zipArchive.Save(name, thumbnail.StreamSource);
}
}
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:7,代码来源:ThumbnailManager.cs
示例4: GetBitmap
/// <summary>
/// Gets a bitmap inside the given assembly at the given path therein.
/// </summary>
/// <param name="uri">
/// The relative URI.
/// </param>
/// <param name="assemblyName">
/// Name of the assembly.
/// </param>
/// <returns>
/// </returns>
public static BitmapImage GetBitmap(Uri uri, string assemblyName)
{
if (uri == null)
{
return null;
}
var stream = GetStream(uri, assemblyName);
if (stream == null)
{
return null;
}
using (stream)
{
var bmp = new BitmapImage();
bmp.BeginInit();
bmp.StreamSource = stream;
bmp.EndInit();
return bmp;
}
}
开发者ID:nukolai,项目名称:xaml-sdk,代码行数:36,代码来源:Extensionutilities.cs
示例5: DownloadPicture
public async Task<ImageSource> DownloadPicture(string imageUri)
{
var request = (HttpWebRequest)WebRequest.Create(imageUri);
if (string.IsNullOrEmpty(Configuration.SessionCookies) == false)
{
request.CookieContainer = new CookieContainer();
request.CookieContainer.SetCookies(request.RequestUri, Configuration.SessionCookies);
}
var response = (HttpWebResponse)(await request.GetResponseAsync());
using (Stream inputStream = response.GetResponseStream())
using (Stream outputStream = new MemoryStream())
{
var buffer = new byte[4096];
int bytesRead;
do
{
bytesRead = await inputStream.ReadAsync(buffer, 0, buffer.Length);
outputStream.Write(buffer, 0, bytesRead);
} while (bytesRead != 0);
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.StreamSource = outputStream;
bitmapImage.EndInit();
bitmapImage.Freeze();
return bitmapImage;
}
}
开发者ID:sceeter89,项目名称:jira-client,代码行数:32,代码来源:ResourceDownloader.cs
示例6: ImportImageButtonClick
private void ImportImageButtonClick(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
#if WPF
openFileDialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp";
#else
openFileDialog.Filter = "Image Files (*.png, *.jpg)|*.png;*.jpg";
#endif
bool? dialogResult = openFileDialog.ShowDialog();
if (dialogResult.HasValue && dialogResult.Value == true)
{
Image image = new Image();
#if WPF
image.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
#else
using (var fileOpenRead = openFileDialog.File.OpenRead())
{
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(fileOpenRead);
image.Source = bitmap;
}
#endif
Viewbox viewBox = new Viewbox() { Stretch = Stretch.Fill, Margin = new Thickness(-4) };
viewBox.Child = image;
RadDiagramShape imageShape = new RadDiagramShape()
{
Content = viewBox
};
this.diagram.Items.Add(imageShape);
}
}
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:31,代码来源:Example.xaml.cs
示例7: ShowImage
//TODO filter by mimetype
public void ShowImage(MemoryStream stream)
{
try
{
stream.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = stream;
bitmapImage.EndInit();
image1.Width = bitmapImage.Width;
image1.Height = bitmapImage.Height;
var screenInfo = GetScreenInfo();
image1.Height = screenInfo.Height - 150;
image1.Width = (image1.Height * bitmapImage.Width) / bitmapImage.Height;
Height = image1.Height + 3;
Width = image1.Width + 3;
image1.Source = bitmapImage;
}
catch (NotSupportedException)
{ }
}
开发者ID:siderevs,项目名称:ZippedImageViewer,代码行数:27,代码来源:ImageCanvas.xaml.cs
示例8: client_getApplicationByIdCompleted
private void client_getApplicationByIdCompleted(object sender, MyService.getApplicationByIdCompletedEventArgs e)
{
string jsonString = e.Result.ToString();
JObject jobj = JObject.Parse(jsonString);
jobj = jobj["Application"] as JObject;
string Id = jobj["Id"].ToString();
string Name = jobj["Name"].ToString();
float Price = float.Parse(jobj["Price"].ToString());
float Rating = float.Parse(jobj["Rating"].ToString());
int Reviews = Int32.Parse(jobj["Reviews"].ToString());
DateTime DatePublished = DateTime.Parse(jobj["DatePublished"].ToString());
string PublisherName = jobj["PublisherName"].ToString();
string ImageUrl = jobj["ImageUrl"].ToString();
pivFirstItem.Text = Name;
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.UriSource = new Uri(ImageUrl);
myBitmapImage.DecodePixelWidth = 300;
myBitmapImage.DecodePixelWidth = 300;
myBitmapImage.DecodePixelType = DecodePixelType.Logical;
img.Source = myBitmapImage;
txtDatePublished.Text = "Date published: "+DatePublished.ToShortDateString();
txtPublisher.Text = "Publisher: "+PublisherName;
txtRating.Text = "Rating: "+Rating.ToString();
txtReviews.Text = "Number of reviews: "+Reviews.ToString();
if (Price > 0)
txtPrice.Text = "Price: $ " + Price.ToString();
else
txtPrice.Text = "This application is free";
}
开发者ID:dansef,项目名称:Windows_Phone_AppZoom,代码行数:33,代码来源:AppDetails.xaml.cs
示例9: MainWindow
public MainWindow()
{
InitializeComponent();
// initialize tabItem array
_tabItems = new List<TabItem>();
// add a tabItem with + in header
_tabAdd = new TabItem();
//get image for header and setup add button
_tabAdd.Style = new Style();
_tabAdd.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x30, 0x30));
_tabAdd.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x30, 0x30));
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(@"pack://application:,,,/Explore10;component/Images/appbar.add.png");
bitmap.EndInit();
Image plus = new Image();
plus.Source = bitmap;
plus.Width = 25;
plus.Height = 25;
_tabAdd.Width = 35;
_tabAdd.Header = plus;
_tabAdd.MouseLeftButtonUp += new MouseButtonEventHandler(tabAdd_MouseLeftButtonUp);
_tabItems.Add(_tabAdd);
// add first tab
//this.AddTabItem();
// bind tab control
tabDynamic.DataContext = _tabItems;
tabDynamic.SelectedIndex = 0;
}
开发者ID:PFCKrutonium,项目名称:Explore10,代码行数:34,代码来源:MainWindow.xaml.cs
示例10: initImageCache
private void initImageCache()
{
// load all images in the "iamges" folder
_imageSources = new Dictionary<string, ImageSource>();
if (!string.IsNullOrEmpty(_imageFolder ) && Directory.Exists(_imageFolder))
{
foreach (var f in Directory.GetFiles(_imageFolder, "*.png", SearchOption.TopDirectoryOnly))
{
if (f != null)
{
var filePath = Path.Combine(_imageFolder, f);
var bmp = new BitmapImage(new Uri(filePath));
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(f);
_imageSources.Add(fileNameWithoutExtension, bmp);
}
}
}
_imageSources.Add(".UIController", new BitmapImage(new Uri(@"/Resources/UIController.png", UriKind.Relative)));
_imageSources.Add(".FlowUIController",
new BitmapImage(new Uri(@"/Resources/UIController.png", UriKind.Relative)));
_imageSources.Add(".AbstractUIController",
new BitmapImage(new Uri(@"/Resources/UIController.png", UriKind.Relative)));
}
开发者ID:stickleprojects,项目名称:ClassOutline,代码行数:29,代码来源:ImageCache.cs
示例11: init
/// <summary>
/// 初始化
/// </summary>
public void init(string[] func_list)
{
for (int i = 0; i < func_list.Length; i++)
{
// 分割线
Image img = new Image();
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(AppConfig.IconPath, UriKind.Relative);
bi.EndInit();
img.Margin = new Thickness(5, (i + 1) * 72 - 20, 0, 0);
img.Width = 150;
img.Height = 10;
img.HorizontalAlignment = HorizontalAlignment.Left;
img.VerticalAlignment = VerticalAlignment.Top;
img.Source = bi;
// 按钮
MainNavButton mnb = new MainNavButton();
mnb.Tag = func_list[i];
mnb.id = i;
mnb.init();
mnb.HorizontalAlignment = HorizontalAlignment.Left;
mnb.VerticalAlignment = VerticalAlignment.Top;
mnb.Margin = new Thickness(0, (i + 1) * 72 - 20 + 3, 0, 0);
if (i == 0)
{
mnb.change_state();
}
mnbs.Add(mnb);
this.main.Children.Add(img);
this.main.Children.Add(mnb);
}
}
开发者ID:ONEWateR,项目名称:FlowMonitor,代码行数:38,代码来源:MainNav.xaml.cs
示例12: GetCharacterPortrait
public static BitmapImage GetCharacterPortrait(Player player)
{
if (player == null || player.CharacterID == 0)
return null;
int Size = 64;
string filePath = string.Format("{0}\\{1}.jpg", Utils.PortraitDir, player.CharacterID);
BitmapImage image = null;
try
{
if (!File.Exists(filePath))
{
WebClient wc = new WebClient();
wc.DownloadFile(
string.Format("http://img.eve.is/serv.asp?s={0}&c={1}", Size, player.CharacterID),
filePath);
}
image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri(filePath,
UriKind.Absolute);
image.EndInit();
}
catch (Exception)
{
}
return image;
}
开发者ID:FredrikL,项目名称:EVEIntel,代码行数:33,代码来源:Character.cs
示例13: ByteArraytoBitmap
public static BitmapImage ByteArraytoBitmap(Byte[] byteArray)
{
MemoryStream stream = new MemoryStream(byteArray);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(stream);
return bitmapImage;
}
开发者ID:Grief-Code,项目名称:kilogram,代码行数:7,代码来源:ImageByteArrayAttachedProperty.cs
示例14: TopWallpaperRenderer
static TopWallpaperRenderer()
{
ScreenArea = new Rect(0, 0, 412, 240);
var defTopAlt = new BitmapImage();
defTopAlt.BeginInit();
//defTopAlt.StreamSource = (Stream) Extensions.GetResources(@"TopAlt_DefMask\.png").First().Value;
defTopAlt.UriSource = new Uri(@"pack://application:,,,/ThemeEditor.WPF;component/Resources/TopAlt_DefMask.png");
defTopAlt.CacheOption = BitmapCacheOption.OnLoad;
defTopAlt.EndInit();
var bgrData = defTopAlt.GetBgr24Data();
RawTexture rTex = new RawTexture(defTopAlt.PixelWidth, defTopAlt.PixelHeight, RawTexture.DataFormat.A8);
rTex.Encode(bgrData);
DefaultTopSquares = new TextureViewModel(rTex, null);
RenderToolFactory.RegisterTool<PenTool, Pen>
(key => new Pen(new SolidColorBrush(key.Color)
{
Opacity = key.Opacity
},
key.Width));
RenderToolFactory.RegisterTool<SolidColorBrushTool, Brush>
(key => new SolidColorBrush(key.Color)
{
Opacity = key.Opacity
});
RenderToolFactory.RegisterTool<LinearGradientBrushTool, Brush>
(key => new LinearGradientBrush(key.ColorA, key.ColorB, key.Angle)
{
Opacity = key.Opacity
});
RenderToolFactory.RegisterTool<ImageBrushTool, Brush>
(key => new ImageBrush(key.Image)
{
TileMode = key.Mode,
ViewportUnits = key.ViewportUnits,
Viewport = key.Viewport,
Opacity = key.Opacity
});
Type ownerType = typeof(TopWallpaperRenderer);
IsEnabledProperty
.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(false, OnIsEnabledChanged));
ClipToBoundsProperty.OverrideMetadata(ownerType,
new FrameworkPropertyMetadata(true, null, (o, value) => true));
WidthProperty.OverrideMetadata(ownerType,
new FrameworkPropertyMetadata(412.0, null, (o, value) => 412.0));
HeightProperty.OverrideMetadata(ownerType,
new FrameworkPropertyMetadata(240.0, null, (o, value) => 240.0));
EffectProperty.OverrideMetadata(ownerType,
new FrameworkPropertyMetadata(default(WarpEffect),
null,
(o, value) => ((TopWallpaperRenderer) o).GetWarpEffectInstance()));
}
开发者ID:cedianoost,项目名称:3DS-Theme-Editor,代码行数:60,代码来源:TopWallpaperRenderer.cs
示例15: busquedaBtn_Click
private void busquedaBtn_Click(object sender, RoutedEventArgs e)
{
Client cliente = ControllerCliente.Instance.buscarCliente(busquedaBox.Text);
if (cliente == null)
{
MessageBox.Show("No existe con ese carnet");
}
else
{
ciBox.Text = cliente.ci.ToString();
nombreBox.Text = cliente.nombre;
PaternoBox.Text = cliente.apellidoPaterno;
MaternoBox.Text = cliente.apellidoMaterno;
DomicilioBox.Text = cliente.domicilio;
ZonaBox.Text = cliente.zona;
emailBox.Text = cliente.email;
telefonoCasaBox.Text = cliente.telefonoCasa;
telefonoOficinaBox.Text = cliente.telefonoOficina;
feCNacimientoBox.Text = cliente.fechaNacimiento.ToString();
sexoBox.Text = cliente.sexo;
BiometricoBox.Text = cliente.codBiometrico;
System.IO.MemoryStream stream = new System.IO.MemoryStream(cliente.foto);
BitmapImage foto = new BitmapImage();
foto.BeginInit();
foto.StreamSource = stream;
foto.CacheOption = BitmapCacheOption.OnLoad;
foto.EndInit();
image.Source = foto;
}
}
开发者ID:irvin373,项目名称:gym,代码行数:31,代码来源:EliminarCliente.xaml.cs
示例16: ExtTreeNode
public ExtTreeNode(Image icon, string title)
: this()
{
if (icon != null)
{
this.icon = icon;
}
else//test inti icon
{
this.icon = new Image();
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.UriSource = new Uri(@"pack://application:,,,/ATNET;component/icons/add.png", UriKind.RelativeOrAbsolute);
//bitmapImage.UriSource = new Uri(@"../../icons/add.png", UriKind.RelativeOrAbsolute);
bitmapImage.EndInit();
this.icon.Source = bitmapImage;
}
this.icon.Width = 16;
this.icon.Height = 16;
this.title = title;
TextBlock tb = new TextBlock();
tb.Text = title;
Grid grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.Children.Add(this.icon);
grid.Children.Add(tb);
Grid.SetColumn(this.icon, 0);
Grid.SetColumn(tb, 1);
this.Header = grid;
}
开发者ID:ichengzi,项目名称:atnets,代码行数:34,代码来源:ExtTreeNode.cs
示例17: apartment_Click
private void apartment_Click(object sender, RoutedEventArgs e)
{
index.DataContext = "1";
indexStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
BitmapImage image1 = new BitmapImage(new Uri("\\icon\\index.png", UriKind.Relative));
indexImg.Source = image1;
undergraduate.DataContext = "1";
undergraduateStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
BitmapImage image2 = new BitmapImage(new Uri("\\icon\\undergraduate.png", UriKind.Relative));
undergraduateImg.Source = image2;
graduate.DataContext = "1";
graduateStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
BitmapImage image3 = new BitmapImage(new Uri("\\icon\\graduate.png", UriKind.Relative));
graduateImg.Source = image3;
document.DataContext = "1";
documentStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
BitmapImage image4 = new BitmapImage(new Uri("\\icon\\document.png", UriKind.Relative));
documentImg.Source = image4;
apartment.DataContext = "2";
currTab.Content = new currTab.apartment();
}
开发者ID:Rorwey,项目名称:msinfosys,代码行数:25,代码来源:MainWindow.xaml.cs
示例18: SplashScreen
public SplashScreen()
{
LoadConfigPrefs();
Image SplashScreen = new Image()
{
Height = Application.Current.Host.Content.ActualHeight,
Width = Application.Current.Host.Content.ActualWidth,
Stretch = Stretch.Fill
};
var imageResource = GetSplashScreenImageResource();
if (imageResource != null)
{
BitmapImage splash_image = new BitmapImage();
splash_image.SetSource(imageResource.Stream);
SplashScreen.Source = splash_image;
}
// Instansiate the popup and set the Child property of Popup to SplashScreen
popup = new Popup() { IsOpen = false,
Child = SplashScreen,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Center
};
}
开发者ID:Carlosps,项目名称:ionicDataBase,代码行数:27,代码来源:SplashScreen.cs
示例19: SignatureWindow
public SignatureWindow(string signature)
{
var digitalSignatureCollection = new List<object>();
digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());
InitializeComponent();
{
var icon = new BitmapImage();
icon.BeginInit();
icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
icon.EndInit();
if (icon.CanFreeze) icon.Freeze();
this.Icon = icon;
}
_signatureComboBox.ItemsSource = digitalSignatureCollection;
for (int index = 0; index < Settings.Instance.Global_DigitalSignatureCollection.Count; index++)
{
if (Settings.Instance.Global_DigitalSignatureCollection[index].ToString() == signature)
{
_signatureComboBox.SelectedIndex = index + 1;
break;
}
}
}
开发者ID:networkelements,项目名称:Amoeba,代码行数:31,代码来源:SignatureWindow.xaml.cs
示例20: SearchButton_Click
private void SearchButton_Click(object sender, RoutedEventArgs e)
{
var result = WeatherService.GetWeatherFor(SearchBox.Text);
string fileUrl = $"{Environment.CurrentDirectory}/{result.icon}.gif";
if (!File.Exists(fileUrl))
{
using (var webClient = new WebClient())
{
byte[] bytes = webClient.DownloadData(result.icon_url);
File.WriteAllBytes(fileUrl, bytes);
}
}
BitmapImage image = new BitmapImage(new Uri(fileUrl));
WeatherImage.Source = image;
// CityBlock.Text = result.full.ToString();
LatiLongBlock.Text = result.latitude.ToString() + "/" + result.longitude.ToString();
WeatherBlock.Text = result.weather.ToString();
TempFBlock.Text = result.temp_f.ToString();
TempCBlock.Text = result.temp_c.ToString();
HumidityBlock.Text = result.relative_humidity.ToString();
WindmphBlock.Text = result.wind_mph.ToString();
WindDirectionBlock.Text = result.wind_dir.ToString();
UVIndexBox.Text = result.UV.ToString();
}
开发者ID:AstraKiseki,项目名称:10-WeatherApp,代码行数:30,代码来源:MainWindow.xaml.cs
注:本文中的System.Windows.Media.Imaging.BitmapImage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论