|
/*
* UserName: Tefik Becirovic
* HomePage: www.Becirovic.eu
* DateTime: 25.01.2012 12:49
*/
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace SlidingImageControl.Test
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.Fant);
}
public ImageSource ImageSourceFromCode
{
get
{
double dpi = 96.0;
int W = 1000, H = 50;
RenderTargetBitmap rtb = new RenderTargetBitmap(W, H, dpi, dpi, PixelFormats.Pbgra32);
Pen pen = new Pen();
pen.Thickness = 3;
pen.LineJoin = PenLineJoin.Round;
pen.EndLineCap = PenLineCap.Round;
pen.Brush = Brushes.DarkMagenta;
Random rnd = new Random();
DrawingVisual visual = new DrawingVisual();
using (DrawingContext dc = visual.RenderOpen())
{
dc.DrawLine(new Pen(Brushes.Black, 1), new Point(0, H / 2), new Point(W, H / 2));
for (int x = 0; x < W / 5; x++)
dc.DrawLine(pen, new Point(5 * x + 2.5, rnd.Next(1, H - 2)), new Point(5 * x + 2.5, H / 2));
}
rtb.Render(visual);
return rtb;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.