本文整理汇总了C#中System.Windows.Controls.Image.Arrange方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Controls.Image.Arrange方法的具体用法?C# System.Windows.Controls.Image.Arrange怎么用?C# System.Windows.Controls.Image.Arrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Image
的用法示例。
在下文中一共展示了System.Windows.Controls.Image.Arrange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: GenerateWindowIcon
/// <summary>
/// Loads the BowIcon from resources and colors it according to the current theme
/// </summary>
/// <returns></returns>
public static RenderTargetBitmap GenerateWindowIcon()
{
var iconImage = new System.Windows.Controls.Image
{
Source = (DrawingImage) Application.Current.MainWindow.Resources["BowIcon"],
Stretch = Stretch.Uniform,
Margin = new Thickness(20)
};
iconImage.Arrange(new Rect(0, 0, 100, 100));
var bitmap = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(iconImage);
return bitmap;
}
示例3: MenuItem_Click_1
private void MenuItem_Click_1(object sender, RoutedEventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
saveFileDialog1.Title = "Save an Image File";
saveFileDialog1.ShowDialog();
if (saveFileDialog1.FileName != "")
{
FileStream stream = new FileStream(saveFileDialog1.FileName, FileMode.Create);
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
// var bitmap = BitmapFrame.Create( );
// TextBlock myTextBlock = new TextBlock();
// myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
// bitmap = image.Source;
//var bitmap = BitmapFrame();
//2. Create an Image control which will accept the DrawingImage as its Source
System.Windows.Controls.Image myImage = new System.Windows.Controls.Image();
myImage.Source = image.Source;
myImage.Arrange(new Rect(0, 0, 500, 500)); //Required
//3. Render the Image control's content to a RenderTargetBitmap
RenderTargetBitmap rtb = new RenderTargetBitmap(500, 500, 96, 96, System.Windows.Media.PixelFormats.Default);
rtb.Render(myImage);
//4. Now the RenderTargetBitmap can be used with the JpegBitmapEncoder
encoder.Frames.Add(BitmapFrame.Create(rtb));
// MessageBox.Show(myPalette.Colors.Count.ToString());
encoder.Save(stream);
stream.Close();
}
}