【发布时间】:2016-02-09 15:28:51
【问题描述】:
我正在从外部网站提取图像,并在固定大小的框中按顺序显示每个图像。设置拉伸图像以填充框的约束,但保持纵横比。因为图像并不总是与盒子的纵横比匹配,所以我在图像周围出现白色条纹。我不知道如何摆脱白带。我在 canvas.before 中尝试使用 Color 尝试将框着色为黑色,但没有成功。
图像(和相关信息)从 Python 推送:
class TheBox(FloatLayout):
def update(self, *args):
..
..
if (total_count % 2) == 0:
if which_petL < quantity:
which_petL += 1
else:
which_petL = 0
self.ids.PetL_photo.source = str(Lphoto)
千伏:
#:kivy 1.9.1
<TheBox>:
FloatLayout:
FloatLayout:
size: 810, 1080
pos_hint: {'center_x': .21}
AsyncImage:
id: PetL_photo
size_hint: None, None
size: 790, 770
pos_hint: {'center_x': .5, 'center_y': .64}
allow_stretch: True
keep_ratio: True
source:
..
..
结果:
http://cselman.com/20160209_093304.mp4
有什么帮助吗?
canvas.before 尝试:
#:kivy 1.9.1
<TheBox>:
FloatLayout:
FloatLayout:
size: 810, 1080
pos_hint: {'center_x': .21}
AsyncImage:
canvas.before:
Color:
rgb: (0, 0, 0)
id: PetL_photo
size_hint: None, None
size: 790, 770
pos_hint: {'center_x': .5, 'center_y': .64}
allow_stretch: True
keep_ratio: True
source:
还有……
#:kivy 1.9.1
<TheBox>:
canvas.before:
Color:
rgb: (0, 0, 0)
FloatLayout:
FloatLayout:
size: 810, 1080
pos_hint: {'center_x': .21}
AsyncImage:
id: PetL_photo
size_hint: None, None
size: 790, 770
pos_hint: {'center_x': .5, 'center_y': .64}
allow_stretch: True
keep_ratio: True
source:
还有……
#:kivy 1.9.1
<TheBox>:
FloatLayout:
FloatLayout:
size: 810, 1080
pos_hint: {'center_x': .21}
canvas.before:
Color:
rgb: (0, 0, 0)
AsyncImage:
id: PetL_photo
size_hint: None, None
size: 790, 770
pos_hint: {'center_x': .5, 'center_y': .64}
allow_stretch: True
keep_ratio: True
source:
【问题讨论】:
-
您能展示一下无效的
canvas.before部分吗?另外,Facebook 链接对我不起作用(也许 b/c 我不在 FB 上) -
使用 canvas.before 时看起来不像是在画布上绘图。尝试添加一个大小和位置设置为 self.size 和 self.pos 的 Rectangle。