You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
}
}
}
The text was updated successfully, but these errors were encountered:
As I remember if you clear the bitmap before draw with some solid colors, with alpha = 255 (no transparency) this problem will not happen. it only happen when drawing AA line on a transparent image. Not sure, so check it yourself.
Thanks
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:
The text was updated successfully, but these errors were encountered: