WriteableBitmap(UIElement,Transform)文本块颜色问题 [英] WriteableBitmap(UIElement,Transform) Textblock color issue

查看:72
本文介绍了WriteableBitmap(UIElement,Transform)文本块颜色问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在下面的代码下面生成一个writeablebitmap,它将使用.Pixels []逐像素渲染到另一个可写位图上.

Hi everyone, I'm following this code below to generate an writeablebitmap which is to be rendered on to another writeable bitmap pixel by pixel using the .Pixels[].

                TextBlock SentanceTextbox = new TextBlock();
                SentanceTextbox.FontSize = 72;
                SentanceTextbox.FontFamily = new FontFamily("Segoe WP");
                SentanceTextbox.Foreground = new SolidColorBrush(Color.FromArgb(255,255,255,255));
                SentanceTextbox.Width = 1600;
                SentanceTextbox.TextWrapping = TextWrapping.Wrap;
                SentanceTextbox.Text = wp.Sentence1;

                WriteableBitmap SentanceBitmap = new WriteableBitmap(SentanceTextbox, SentanceTextbox.RenderTransform);

唯一的问题是,一旦将生成的图像写到源上,它们的字母上就会有黑色的轮廓.

Only problem is that there are black color outlines to the letters in the generated image once it has been written on to the source.

您可以从此屏幕剪辑中看到我的意思,该屏幕剪辑取自可写结果位图的jpg.我想知道是否有人知道导致此问题的原因,当然有什么方法可以避免它吗?

You can see what I mean from this screen clipping taken from a jpg of the result writeable bitmap. I was wondering if anyone would know what is causing this problem and of course is there anyway to avoid it?

我尝试过替换黑白像素,但实际上也替换了所有透明像素(即使我设置了显式值,也不替换范围).正在渲染的字体大小为16,正在创建的图像 是2900x2000

I've tried replacing pixels which are black to white but that actually replaces all the transparent pixels as well (even it I set explicit values, not ranges for replacement). The Font size which is being rendered is 16, and the image which is being created is 2900x2000

是否可能与jpg压缩有关?我以为不是,因为我在UI压缩之前先渲染图像.

Is it possible that it could be related to jpg compression? I thought not because I render the image before it is compressed in the UI.

感谢您的帮助,

Dan

推荐答案

这可能是由于字体渲染过程中使用了抗锯齿功能.

This is probably due to the anti-aliasing used in the font rendering process.

http://en.wikipedia.org/wiki/Font_rasterization

您可以尝试使用

You can experiment with TextFormattingMode but I suspect you may need to take a different approach in your design.

希望这会有所帮助,
标记

Hope this helps,
Mark


这篇关于WriteableBitmap(UIElement,Transform)文本块颜色问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆