怎样绘制一个位图(的WinForms)易读的文本? [英] How can I draw legible text on a bitmap (Winforms)?

查看:155
本文介绍了怎样绘制一个位图(的WinForms)易读的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个照片浏览器,我想在叠加照片文本。我想要的字体或字体颜色,使文本清晰地对位图的顶部,不管底层的位图的样子。

I've written a photo viewer, and I want to superimpose text over the photo. I want the font or font color to make the text as legible as possible on top of the bitmap, no matter what the underlying bitmap looks like.

我现在的想法是把那里的文字将显示位图的区域,并做出某种该区域整体颜色的计算,然后设置字体颜色要的东西相应地形成鲜明对比。

My current thinking is to take the region of the bitmap where the text will appear, and make some kind of "overall color" calculation for that area, and then set the font color to be something correspondingly contrasting.

不过,这是数学在我头上的方式。有人看到制作这种类型的什么是所有这些像素的平均色的计算方法?或者是说甚至不是最好的方法?

However, this math is way over my head. Has anybody seen a method for making this type of "what's the average color of all of these pixels" calculation? Or is that not even the best approach?

编辑:我移动的这个第二部分的另一个问题

I'm moving the second portion of this to another question.

推荐答案

您可以用它来计算出位图的区域的平均色彩:
<一href=\"http://stackoverflow.com/questions/1068373/how-to-calculate-the-average-rgb-color-values-of-a-bitmap\">How计算位图的平均RGB颜色值
你的图像保存为位图

You can use this to calculate average color of a region of bitmap: How to calculate the average rgb color values of a bitmap Do you store your image as a Bitmap?

您也可以得出一个概括的文字。例如,白字黑边。这将使大部分的背景文字可见:
如何使用大纲绘制文本到影像?

You can also draw an outlined text. For example, white text with black outline. This will make text visible on most of backgrounds: How to Drawing Text with Outline onto Images?

这篇关于怎样绘制一个位图(的WinForms)易读的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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