对未知背景的可见性 [英] Visibility against an unknown background

查看:66
本文介绍了对未知背景的可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用wxPython在图片上绘制可见的线条。这意味着我不能简单地使用例如一条黑线,因为它不会在黑色或黑色的图片上显示出来。




像GIMP这样的绘画应用程序通过根据它所覆盖的像素颜色改变线条的颜色来实现这一点,但

唯一的方法我可以想到这样做是为了获得每个像素,然后在屏幕上绘制它的颜色,然后将它绘制在屏幕上,这似乎是一种非常低效的方式。


我可以在线条上使用交替颜色,但我不认为

对我的品味来说足够好。


我想我会在

适当位置使用一个带有孔的部分透明位图,并根据需要移动孔。


我意识到最后的解决方案,因为我写这篇文章,我认为它将会很好地工作,但我仍然想知道是否还有其他更优惠的解决方案我可能错过了。


/ Odalrick

解决方案

" Odalrick" < od ****** @ hotmail.comwrote in message

news:11 ********************* @ e3g2000cwe。 googlegrou ps.com ...


>我需要使用wxPython在图片上绘制可见的线条。这意味着我不能简单地使用例如一条黑线,因为它不会在黑色或黑色的图片上显示出来。




像GIMP这样的绘画应用程序通过根据它所覆盖的像素颜色改变线条的颜色来实现这一点,但

唯一的方法我可以想到这样做是为了获得每个像素,然后在屏幕上绘制它的颜色,然后将它绘制在屏幕上,这似乎是一种非常低效的方式。


我可以在线条上使用交替颜色,但我不认为

对我的品味来说足够好。


我想我会在

适当位置使用一个带有孔的部分透明位图,并根据需要移动孔。


我意识到最后的解决方案,因为我写这篇文章,我认为它将会很好地工作,但我仍然想知道是否还有其他更优惠的解决方案我可能错过了


/ Odalrick



你可以试试浅色的轮廓。例如,绘制一个3像素宽的白色或浅灰色的b $ b白色或浅灰色线,然后覆盖你的1像素宽的黑色线条。

在浅色背景下,轮廓会消失;在黑暗的背景下,

轮廓在背景中看起来像一个洞,以显示你的黑线。


- Paul


2006-10-24,Odalrick< od ****** @ hotmail.comwrote:


我需要画画wxPython图片上的可见线条。这意味着我不能简单地使用例如一条黑线,因为它不会在黑色或黑色的图片上显示出来。




像GIMP这样的绘画应用程序通过根据它所覆盖的像素颜色改变线条的颜色来实现这一点,



是的。


但是我能想到的唯一方法是获得每个

像素,然后改变颜色然后绘画它在屏幕上,

这似乎是一种非常低效的方式。



这不是一般的做法。当你画一条线时,大多数

图形工具包允许你指定一个操作符。那就是

应用于现有像素和线条颜色来确定新的像素颜色。在不同颜色的东西上绘制线条的传统方法是使用xor和xor。操作员当

画线。


-

格兰特爱德华兹格兰特哇!你可以在CAKE邮寄一个豆子

吗?

visi.com


2006-10-24,格兰特Edwards< gr **** @ visi.comwrote:


2006-10-24,Odalrick< od ****** @ hotmail.comwrote :


>我需要使用wxPython在图片上绘制可见的线条。这意味着我不能简单地使用黑色线条,因为它在黑色或黑色图片上不可见。

GIMP等绘画应用程序完成这可以根据它所覆盖的像素的颜色改变线条的颜色,



是的。


>但我能想到的唯一方法是获取每个像素,转换颜色然后在屏幕上绘制它,这似乎是一种非常低效的方式。



这不是一般的做法。当你画一条线时,大多数

图形工具包允许你指定一个操作符。那就是

应用于现有像素和线条颜色来确定新的像素颜色。在不同颜色的东西上绘制线条的传统方法是使用xor和xor。操作员当

绘制线条时。



哦,使用xor运算符的另一大好处是你可以通过简单的方式将像素图恢复到原始状态

重复完全相同的画线操作。这使得它可以像橡皮筋那样琐碎。


-

格兰特爱德华兹格兰特哇!我忘了我的

在整个生活哲学中!!!

visi.com


I need to draw visible lines on pictures with wxPython. That means I
can''t simply use, for instance, a black line since it wont be visible
on a black or dark picture.

Painting applications like the GIMP accomplish this by altering the
colour of the line based on the colour of the pixel it covers, but the
only way I can think of doing that is getting each pixel, transforming
the colour then painting it on the screen, which seems like a horribly
inefficient way do it.

I could use alternating colour on the lines, but I don''t think that
will be good enough for my taste.

I think I will use a partially transparent bitmap with a hole in the
appropriate place and move the hole as needed.

I realized the last solution as I was writing this and I think it will
work fairly well, but I''m still wondering if there is another, better
solution i might have missed.

/Odalrick

解决方案

"Odalrick" <od******@hotmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...

>I need to draw visible lines on pictures with wxPython. That means I
can''t simply use, for instance, a black line since it wont be visible
on a black or dark picture.

Painting applications like the GIMP accomplish this by altering the
colour of the line based on the colour of the pixel it covers, but the
only way I can think of doing that is getting each pixel, transforming
the colour then painting it on the screen, which seems like a horribly
inefficient way do it.

I could use alternating colour on the lines, but I don''t think that
will be good enough for my taste.

I think I will use a partially transparent bitmap with a hole in the
appropriate place and move the hole as needed.

I realized the last solution as I was writing this and I think it will
work fairly well, but I''m still wondering if there is another, better
solution i might have missed.

/Odalrick

You could try outlining in a light color. For example, draw a 3-pixel-wide
white or light gray line, and then overlay your 1-pixel-wide black line.
Over light backgrounds, the outline will disappear; over dark backgrounds,
the outline will look like a hole in the background to show your black line.

-- Paul


On 2006-10-24, Odalrick <od******@hotmail.comwrote:

I need to draw visible lines on pictures with wxPython. That means I
can''t simply use, for instance, a black line since it wont be visible
on a black or dark picture.

Painting applications like the GIMP accomplish this by altering the
colour of the line based on the colour of the pixel it covers,

Yup.

but the only way I can think of doing that is getting each
pixel, transforming the colour then painting it on the screen,
which seems like a horribly inefficient way do it.

That''s not how it''s generally done. When you draw a line, most
graphics toolkits allow you to specify an "operator" that is
applied to the existing pixel and the line-color to determine
the new pixel color. The traditional way to draw lines on
something with varying colors is to use the "xor" operator when
drawing the lines.

--
Grant Edwards grante Yow! Can you MAIL a BEAN
at CAKE?
visi.com


On 2006-10-24, Grant Edwards <gr****@visi.comwrote:

On 2006-10-24, Odalrick <od******@hotmail.comwrote:

>I need to draw visible lines on pictures with wxPython. That means I
can''t simply use, for instance, a black line since it wont be visible
on a black or dark picture.

Painting applications like the GIMP accomplish this by altering the
colour of the line based on the colour of the pixel it covers,


Yup.

>but the only way I can think of doing that is getting each
pixel, transforming the colour then painting it on the screen,
which seems like a horribly inefficient way do it.


That''s not how it''s generally done. When you draw a line, most
graphics toolkits allow you to specify an "operator" that is
applied to the existing pixel and the line-color to determine
the new pixel color. The traditional way to draw lines on
something with varying colors is to use the "xor" operator when
drawing the lines.

Oh, another big benefit from using the xor operator is that you
can restore the pixmap to it''s original state by simply
repeating the exact same line-draw operation. That makes it
trivial to do things like rubber-banding.

--
Grant Edwards grante Yow! I just forgot my
at whole philosophy of life!!!
visi.com


这篇关于对未知背景的可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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