本文整理汇总了C#中Image.EndInit方法的典型用法代码示例。如果您正苦于以下问题:C# Image.EndInit方法的具体用法?C# Image.EndInit怎么用?C# Image.EndInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.EndInit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSelectedItemChanged
private void OnSelectedItemChanged(IImgObject selectedObj)
{
var img = selectedObj as ImgImage;
if (img != null)
{
var imgCtrl = new Image();
imgCtrl.BeginInit();
{
imgCtrl.Source = img.GetImageSource();
imgCtrl.HorizontalAlignment = HorizontalAlignment.Left;
imgCtrl.VerticalAlignment = VerticalAlignment.Top;
}
imgCtrl.EndInit();
ImgCanvas.Children.Clear();
ImgCanvas.Children.Add(imgCtrl);
ImgCanvas.Width = img.Width;
this.orgImgWidth = img.Width;
ImgCanvas.Height = img.Height;
this.orgImgHeight = img.Height;
(this.DataContext as ImageDetailViewModel).TargetImage = img;
}
}
示例2: addt
public void addt(String url)
{
Image image = new Image();
image.BeginInit();
image.Source = new BitmapImage(new Uri(url));
image.EndInit();
image.Width = 100;
image.Height = 100;
image.Stretch = Stretch.Uniform;
image.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
image.VerticalAlignment = System.Windows.VerticalAlignment.Top;
myg.Children.Add(image);
}
示例3: Convert
/// <summary>
/// Converts an <see cref="ImageSource"/> into an <see cref="Image"/>.
/// </summary>
/// <param name="value">The value produced by the binding source.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var inputImage = value as ImageSource;
if (inputImage != null)
{
var image = new Image();
image.BeginInit();
image.Source = inputImage;
image.EndInit();
return image;
}
return DependencyProperty.UnsetValue;
}
示例4: GetInfoObject
public UIElement GetInfoObject(double width)
{
if(string.IsNullOrEmpty(Path))
{
throw new ArgumentNullException("Path cannot be null");
}
var img = new Image();
img.BeginInit();
img.Source = new BitmapImage(new Uri("/CozyLauncher.Plugin.Guide;component/" + Path, UriKind.RelativeOrAbsolute));
img.Stretch = Stretch.Fill;
img.EndInit();
img.MaxWidth = width;
return img;
}
示例5: AddButton
public void AddButton(ImageSource imgSrc)
{
Image img = new Image();
img.BeginInit();
img.Width = BUTTON_SIZE;
img.Height = BUTTON_SIZE;
img.Source = imgSrc;
img.EndInit();
buttons.Add(img);
wheelCanvas.Children.Add(img);
if (IsInitialized)
{
refreshButtons();
}
}
示例6: initializeButtonImages
private void initializeButtonImages()
{
leftButton = new Image();
leftButton.BeginInit();
BitmapImage bmp = new BitmapImage(new Uri(@"C:\Users\Kartikeya\Documents\Visual Studio 2010\Projects\Share\Share\left.png", UriKind.Absolute));
bmp.CacheOption = BitmapCacheOption.OnLoad;
leftButton.Source = bmp;
leftButton.EndInit();
leftButton.Height = 100;
leftButton.Width = 100;
galleryButton = new Image();
galleryButton.BeginInit();
bmp = new BitmapImage(new Uri(@"C:\Users\Kartikeya\Documents\Visual Studio 2010\Projects\Share\Share\gallery.jpg", UriKind.Absolute));
bmp.CacheOption = BitmapCacheOption.OnLoad;
galleryButton.Source = bmp;
galleryButton.EndInit();
galleryButton.Height = 100;
galleryButton.Width = 100;
rightButton = new Image();
rightButton.BeginInit();
bmp = new BitmapImage(new Uri(@"C:\Users\Kartikeya\Documents\Visual Studio 2010\Projects\Share\Share\right.png", UriKind.Absolute));
bmp.CacheOption = BitmapCacheOption.OnLoad;
rightButton.Source = bmp;
rightButton.EndInit();
rightButton.Height = 100;
rightButton.Width = 100;
trashButton = new Image();
trashButton.BeginInit();
bmp = new BitmapImage(new Uri(@"C:\Users\Kartikeya\Documents\Visual Studio 2010\Projects\Share\Share\trash.png", UriKind.Absolute));
bmp.CacheOption = BitmapCacheOption.OnLoad;
trashButton.Source = bmp;
trashButton.EndInit();
trashButton.Height = 100;
trashButton.Width = 100;
}
示例7: SetImage
//change l'image d'un bouton pour le chemin spécifié
private void SetImage(string path, Button b)
{
Image i = new Image();
i.BeginInit();
i.Source = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
i.EndInit();
b.Content = i;
}
示例8: ExecuteThread
public string ExecuteThread(FileItem item,string infile, string dest, ValuePairEnumerator configData)
{
try
{
var conf = new OverlayTransformViewModel(configData);
using (var fileStream = new MemoryStream(File.ReadAllBytes(infile)))
{
BitmapDecoder bmpDec = BitmapDecoder.Create(fileStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.OnLoad);
WriteableBitmap writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames[0]);
writeableBitmap.Freeze();
Grid grid = new Grid
{
Width = writeableBitmap.PixelWidth,
Height = writeableBitmap.PixelHeight,
ClipToBounds = true,
SnapsToDevicePixels = true
};
grid.UpdateLayout();
var size = new Size(writeableBitmap.PixelWidth, writeableBitmap.PixelWidth);
grid.Measure(size);
grid.Arrange(new Rect(size));
Image overlay = new Image();
Image image = new Image { Width = writeableBitmap.PixelWidth, Height = writeableBitmap.PixelHeight };
image.BeginInit();
image.Source = writeableBitmap;
image.EndInit();
image.Stretch = Stretch.Fill;
grid.Children.Add(image);
grid.UpdateLayout();
string text = "";
if (!string.IsNullOrEmpty(conf.Text))
{
Regex regPattern = new Regex(@"\[(.*?)\]", RegexOptions.Singleline);
MatchCollection matchX = regPattern.Matches(conf.Text);
text = matchX.Cast<Match>()
.Aggregate(conf.Text,
(current1, match) =>
item.FileNameTemplates.Where(
template =>
String.Compare(template.Name, match.Value,
StringComparison.InvariantCultureIgnoreCase) == 0).Aggregate(current1,
(current, template) => current.Replace(match.Value, template.Value)));
}
TextBlock textBlock = new TextBlock
{
Text = text,
Foreground = (SolidColorBrush) new BrushConverter().ConvertFromString(conf.FontColor),
FontFamily = (FontFamily) new FontFamilyConverter().ConvertFromString(conf.Font),
FontSize = conf.FontSize,
Opacity = conf.Transparency/100.00
};
if (conf.A11)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Left;
textBlock.VerticalAlignment = VerticalAlignment.Top;
}
if (conf.A12)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Top;
}
if (conf.A13)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Right;
textBlock.VerticalAlignment = VerticalAlignment.Top;
}
if (conf.A21)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Left;
textBlock.VerticalAlignment = VerticalAlignment.Center;
}
if (conf.A22)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Center;
}
if (conf.A23)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Right;
textBlock.VerticalAlignment = VerticalAlignment.Center;
}
if (conf.A31)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Left;
textBlock.VerticalAlignment = VerticalAlignment.Bottom;
}
if (conf.A32)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Bottom;
}
if (conf.A33)
{
textBlock.HorizontalAlignment = HorizontalAlignment.Right;
//.........这里部分代码省略.........
示例9: TileToImage
private static Image TileToImage(byte[] tile)
{
var stream = new MemoryStream(tile);
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = stream;
bitmapImage.EndInit();
var image = new Image();
image.BeginInit();
image.Source = bitmapImage;
image.EndInit();
return image;
}
示例10: CreateThisButton
//.........这里部分代码省略.........
if (BeforeImageAttribute != null)
{
BeforeImagePath = GetButtonFileName(BeforeImageAttribute.Value);
if (!File.Exists(BeforeImagePath))
{
throw new Exception("HandleAllButtonPage.CreateThisButton\r\n" +
"Der File (\"" + BeforeImagePath + "\") für ein Before-Image fehlt");
BeforeImagePath = null;
}
}
if (AfterImageAttribute != null)
{
AfterImagePath = GetButtonFileName(AfterImageAttribute.Value);
if (!File.Exists(AfterImagePath))
{
throw new Exception("HandleAllButtonPage.CreateThisButton\r\n" +
"Der File (\"" + AfterImagePath + "\") für ein After-Image fehlt");
AfterImagePath = null;
}
}
int ButtonColumn = Convert.ToInt32(ColumnAttribute.Value);
int ButtonRow = Convert.ToInt32(RowAttribute.Value);
if (!String.IsNullOrEmpty(BeforeImagePath))
{
beforeImageSource = ConvertFileNameToBitmapImage(BeforeImagePath);
}
if (!String.IsNullOrEmpty(AfterImagePath))
{
afterImageSource = ConvertFileNameToBitmapImage(AfterImagePath);
}
if (RootIsDynamic == false && (afterImageSource == null))
{
column2 = new GridLength(1, GridUnitType.Star);
column3 = new GridLength(1, GridUnitType.Pixel);
}
Button rootButton = new Button();
rootButton.Style = mybuttonstyle;
rootButton.Tag = ButtonEntry;
Grid buttonGrid = new Grid();
buttonGrid.ColumnDefinitions.Add(new ColumnDefinition());
buttonGrid.ColumnDefinitions.Add(new ColumnDefinition());
buttonGrid.ColumnDefinitions.Add(new ColumnDefinition());
buttonGrid.ColumnDefinitions[0].Width = column1;
buttonGrid.ColumnDefinitions[1].Width = column2;
buttonGrid.ColumnDefinitions[2].Width = column3;
Image imagebefore = new Image();
if (beforeImageSource != null)
{
imagebefore.BeginInit();
imagebefore.MaxHeight = beforeImageSource.Height;
imagebefore.MaxWidth = beforeImageSource.Width;
imagebefore.Source = beforeImageSource;
imagebefore.EndInit();
}
imagebefore.Style = beforeImageStyle;
Image imageafter = new Image();
if (afterImageSource != null)
{
imageafter.BeginInit();
imageafter.MaxHeight = afterImageSource.Height;
imageafter.MaxWidth = afterImageSource.Width;
imageafter.Source = afterImageSource;
imageafter.EndInit();
}
imageafter.Style = afterImageStyle;
TextBlock textBlock = new TextBlock();
textBlock.Style = textBlockStyle;
textBlock.Text = Text;
buttonGrid.Children.Add(imagebefore);
buttonGrid.Children.Add(textBlock);
buttonGrid.Children.Add(imageafter);
Grid.SetColumn(imagebefore, 0);
Grid.SetColumn(textBlock, 1);
Grid.SetColumn(imageafter, 2);
rootButton.Content = buttonGrid;
if (RootIsDynamic == true)
{
Button_Grid_Root.Children.Add(rootButton);
}
else
{
Static_Grid_Root.Children.Add(rootButton);
}
Grid.SetColumn(rootButton, ButtonColumn);
Grid.SetRow(rootButton, ButtonRow);
rootButton.Click += ButtonClickEventHandler;
}
示例11: DrawImage
private double DrawImage(Canvas canvas, MemoryStream memoryStream, Rect dest, TileInfo tile)
{
Image image = images.Find(tile.Index);
if (image == null)
{
image = new Image();
memoryStream.Seek(0, SeekOrigin.Begin);
BitmapSource source = BitmapFrame.Create(memoryStream);
image.BeginInit();
image.Source = source;
image.EndInit();
images.Add(tile.Index, image);
Canvas.SetZIndex(image, tile.Index.Level);
image.Opacity = 0;
AnimateOpacity(image, 0, 1, 600);
}
if (!canvas.Children.Contains(image))
canvas.Children.Add(image);
Rect destRounded = new Rect(
new Point(
Math.Round(dest.X) - 0.5,
Math.Round(dest.Y) - 0.5),
new Point(
Math.Round(dest.X + dest.Width) + 0.5,
Math.Round(dest.Y + dest.Height) + 0.5));
Canvas.SetLeft(image, destRounded.X);
Canvas.SetTop(image, destRounded.Y);
image.Width = destRounded.Width;
image.Height = destRounded.Height;
image.Visibility = Visibility.Visible;
return image.Opacity;
}
示例12: ShowBitmapSource
private void ShowBitmapSource (BitmapSource ClipboardContentImage, String ContentFormatParameter)
{
Window BitmapWindow = new Window ();
BitmapWindow.Title = ContentFormatParameter;
ScrollViewer Scroll = new ScrollViewer ();
BitmapWindow.Content = Scroll;
Image BitmapImage = new Image ();
BitmapImage.BeginInit ();
BitmapImage.Source = ClipboardContentImage;
BitmapImage.EndInit ();
Scroll.Content = BitmapImage;
BitmapWindow.ShowDialog ();
}