-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
I wonder if I do something wrong of there is a bug.
Please look at the result obtained from simple modifications of you example: TextExample (attached image).

Code:
namespace WriteableBitmapEx.TextExample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.SizeChanged += MainWindow_SizeChanged;
}
private void MainWindow_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.IsVisible)
Draw();
}
WriteableBitmap bmp;
private void Draw()
{
// double DIP = GetDpi(this);
// var bmp = LoadFromFile("Assets/Overlays/19.jpg");
var parent = UiUtility.GetVisualParent(imgMain);
DependencyObject doParent = VisualTreeHelper.GetParent(imgMain);
int height = (int)parent.ActualHeight;
int width = (int)parent.ActualWidth;
var bmp = BitmapFactory.New(width, height);
System.Windows.Media.FormattedText formattedText;
{
System.Windows.FontStyle fontStyle = FontStyles.Normal;
FontWeight fontWeight = FontWeights.Medium;
var Text = "Now supports text!";
var FontSize = 80;
// var Font = new FontFamily("Sans MS");
var Font = new FontFamily("Arial");
// Create the formatted text based on the properties set.
formattedText = new FormattedText(Text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface("Arial"), FontSize, Brushes.Black); // This brush does not matter since we use the geometry of the text.
// var t = new PixelsPerDip();
}
bmp.DrawTextAa(formattedText, 0, 100, Colors.Black, 7);
bmp.FillText(formattedText, 0, 100, Colors.Red);
int[] points = { 10, 450, 60, 480, 120, 440, 180, 495, 250, 450 };
bmp.DrawPolylineAa(points, Colors.Yellow, 7);
imgMain.Source = bmp;
// bmp.DrawTextAa()
}
public static WriteableBitmap LoadFromFile(string fileName)
{
using (var fileStream = File.OpenRead(fileName))
{
var wb = BitmapFactory.FromStream(fileStream);
return wb;
}
}
}
}
Metadata
Metadata
Assignees
Labels
No labels