本文整理汇总了C#中System.Windows.Media.Imaging.BitmapImage类的典型用法代码示例。如果您正苦于以下问题:C# BitmapImage类的具体用法?C# BitmapImage怎么用?C# BitmapImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapImage类属于System.Windows.Media.Imaging命名空间,在下文中一共展示了BitmapImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
示例3: using
void IThumbnailManager.SetThumbnail(string name, BitmapImage thumbnail)
{
using (var zipArchive = new ZipArchive("AssetThumbnails.zip"))
{
zipArchive.Save(name, thumbnail.StreamSource);
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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)
{ }
}
示例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";
}
示例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;
}
示例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)));
}
示例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);
}
}
示例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;
}
示例13: ByteArraytoBitmap
public static BitmapImage ByteArraytoBitmap(Byte[] byteArray)
{
MemoryStream stream = new MemoryStream(byteArray);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(stream);
return bitmapImage;
}
示例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()));
}
示例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;
}
}