Python 杂波演员的内容并不像它应该的那样混合
由于ClutterTexture现在被标记为已弃用,因此我按照建议将其替换为内容设置为pixbuf的ClutterActorPython 杂波演员的内容并不像它应该的那样混合,python,opacity,clutter,gdkpixbuf,Python,Opacity,Clutter,Gdkpixbuf,由于ClutterTexture现在被标记为已弃用,因此我按照建议将其替换为内容设置为pixbuf的ClutterActor from gi.repository import Clutter, GdkPixbuf, Cogl Clutter.init([]) stage = Clutter.Stage() stage.set_size(600, 300) # old style texture_actor = Clutter.Texture(filename='icon_big_a.png
from gi.repository import Clutter, GdkPixbuf, Cogl
Clutter.init([])
stage = Clutter.Stage()
stage.set_size(600, 300)
# old style
texture_actor = Clutter.Texture(filename='icon_big_a.png')
texture_actor.set_opacity(127)
stage.add_child(texture_actor)
# replacement because ClutterTexture is deprecated
pixbuf = GdkPixbuf.Pixbuf.new_from_file('icon_big_b.png')
pixel_format = Cogl.PixelFormat.RGBA_8888 if pixbuf.get_has_alpha() \
else Cogl.PixelFormat.RGB_888
image = Clutter.Image()
image.set_data(
pixbuf.get_pixels(),
pixel_format,
pixbuf.get_width(),
pixbuf.get_height(),
pixbuf.get_rowstride(),
)
image_actor = Clutter.Actor()
image_actor.set_content_scaling_filters(
Clutter.ScalingFilter.TRILINEAR,
Clutter.ScalingFilter.LINEAR
)
image_actor.set_content(image)
image_actor.set_size(pixbuf.get_width(), pixbuf.get_height())
image_actor.set_opacity(127)
image_actor.move_by(300, 0)
stage.add_child(image_actor)
stage.show()
Clutter.main()
一切都正常,但当我将演员的不透明度更改为127时,即使背景是白色,背景也会变暗
当我将不透明度设置为255时,所有内容看起来都应该是白色的。您需要将杂波版本更新为大于或等于1.16.2的版本(最新的1.16版本是1.16.4)。
ClutterImage
中存在一个错误,导致混合色被不必要地预乘: