在图像上绘制对比字符串 [英] Drawing a contrasted string on an image

查看:67
本文介绍了在图像上绘制对比字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个视频源的快照,我将其捕获到Image中,为其获取一个Graphics对象,然后在该图像的右下角绘制一个时间戳.到目前为止没有问题.但是,我不能保证文本后面会显示什么颜色,因此,无论我使用哪种画笔,它几乎都肯定会与绘制在其上的某些图像发生冲突,从而使文本不可读.

So, I have a snapshot of a video source, which I get into an Image, grab a Graphics object for it, and then draw a timestamp in the bottom right of the image. No problem thus far. However, I cannot guarantee what colour is going to be behind the text, so no matter what brush I use, it will almost certainly clash with some of the images that it is drawn on, making the text unreadable.

我想知道是否有人知道一种方法(基于.net中的方法,还是一种不错的算法),用于根据其后的图像确定字符串的最佳颜色.

I am wondering if anyone knows of a way (either a method in .net, or a nice algorithm), for determining the best colour for a string based on the image behind it.

欢呼

推荐答案

 just draw the string 5 times.
 One time 1(or2) pixels to the left in black
 One time 1(or2) pixels to the right in black
 One time 1(or2) pixels above it in black
 One time 1(or2) pixels below it in black
 and the final time in white on the place where you want it

这篇关于在图像上绘制对比字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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