-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Padding and Background #417
Comments
What's the input formula? What do you mean by the "padding area"? |
I mean this (space), you called it (x,y)
The background color applied to the bounds of the png and the rest of image remain transparent. Any formula does not matter: |
And you set the background by calling |
I use this way:
|
First things first, for further investigation, here's a full snipped I was able to somewhat reproduce the issue with: private void DoTest()
{
var parser = WpfTeXFormulaParser.Instance;
var latexformula = parser.Parse(@"\matrix{1 & 2 & 3 \\ 4 & 5 & 6}");
var mediaTextClr = System.Windows.Media.Color.FromRgb(0, 0, 0);
var textsolidbrush = new System.Windows.Media.SolidColorBrush(mediaTextClr);
var textBrush = WpfMath.Rendering.WpfBrush.FromBrush(textsolidbrush);
latexformula.SetForeground(textBrush);
var mediaBackClr = System.Windows.Media.Color.FromArgb(0xff, 0xff, 0, 0);
var backsolidbrush = new System.Windows.Media.SolidColorBrush(mediaBackClr);
var backBrush = WpfMath.Rendering.WpfBrush.FromBrush(backsolidbrush);
latexformula.SetBackground(backBrush);
var pngBytes = latexformula.RenderToPng(100, 10, 10, "Arial");
File.WriteAllBytes(@"T:\Temp\foo.png", pngBytes);
} For whatever reason, this adds a padding of about 10 transparent pixels around the whole image. (while I'd expect that to only move it from the top left corner by 10 px, and not add padding around everything) Notably, even after replacing There's apparently one transparent pixel to the right and one semi-transparent to the bottom. The core reason is that the image consists of various primitives, and Ideally, the bounding box of the root primitive would be the same as the whole image (well, without this weird padding), but in reality apparently it is not. So, my first advice is to remove the padding from your call to I have an idea how to make it even better, but it would be much easier if we provided a method requested in #289. My idea is to just create a canvas filled with the background color, and then add the result generated by WPF-Math to it. This is doable, but I've tried to write some code using a (horrible) I am leaving the issue open because we'll need to think on how to improve the API to provide better background handling. And also, yeah, implement the API for #289. |
Thank you very much fo you work and effort
And the new update works well now latex.mp4 |
Having semi-recently rewritten the image export code (using |
Hi
t.mp4 |
Yep, folks, that's what I meant. I am still unsure on how to better integrate this with the rest of XAML-Math API. Maybe an additional parameter of Also, while it's totally fine for your end-user app, I'd like to avoid, if possible, using It may be already fixed, or maybe I am misremembering, but still: conceptually, it would be better to stay in pure WPF (in a WPF-related part of the library, of course; again, not talking about an end-user app where the user is free to do whatever they choose). |
Hi
The padding area remain transparent , is there a solution for that?
The text was updated successfully, but these errors were encountered: