1 from Screens.Screen import Screen
2 from Components.Sources.CanvasSource import CanvasSource
3 from Components.ActionMap import ActionMap
4 from enigma import gFont
5 from enigma import RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_VALIGN_CENTER, RT_WRAP
8 return (r<<16)|(g<<8)|b
10 class VideoFinetune(Screen):
12 <screen position="0,0" size="720,576">
13 <widget source="Canvas" render="Canvas" position="0,0" size="720,576" />
16 def __init__(self, session):
17 Screen.__init__(self, session)
18 self["Canvas"] = CanvasSource()
20 self.basic_colors = [RGB(255, 255, 255), RGB(255, 255, 0), RGB(0, 255, 255), RGB(0, 255, 0), RGB(255, 0, 255), RGB(255, 0, 0), RGB(0, 0, 255), RGB(0, 0, 0)]
22 self["actions"] = ActionMap(["InputActions", "OkCancelActions"],
24 "1": self.testpic_brightness,
25 "2": self.testpic_contrast,
26 "3": self.testpic_colors,
27 "4": self.testpic_filter,
28 "5": self.testpic_gamma,
29 "6": self.testpic_fubk,
33 self.testpic_brightness()
39 def bbox(self, x, y, width, height, col, xx, yy):
41 c.fill(x, y, xx, yy, col)
42 c.fill(x + width - xx, y, xx, yy, col)
43 c.fill(x, y + height - yy, xx, yy, col)
44 c.fill(x + width - xx, y + height - yy, xx, yy, col)
46 def testpic_brightness(self):
47 self.next = self.testpic_contrast
52 bbw, bbh = xres / 192, yres / 192
53 c.fill(0, 0, xres, yres, RGB(0,0,0))
56 # col = (7-i) * 255 / 7
57 # width = xres - xres/5
59 # offset = xres/10 + ew * i
63 # c.fill(offset, y, ew, height, RGB(col, col, col))
65 # if col == 0 or col == 16 or col == 116:
66 # self.bbox(offset, y, ew, height, RGB(255,255,255), bbw, bbh)
72 offset = yres/6 + eh * i
76 c.fill(x, offset, width, eh, RGB(col, col, col))
77 if col == 0 or col == 16 or col == 116:
78 c.fill(x, offset, width, 2, RGB(255, 255, 255))
79 # if col == 0 or col == 36:
80 # self.bbox(x, offset, width, eh, RGB(255,255,255), bbw, bbh)
82 c.writeText(x + width, offset, width, eh, RGB(255, 255, 255), RGB(0,0,0), gFont("Regular", 20), "%d." % (i+1))
84 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,255,255), RGB(0,0,0), gFont("Regular", 40),
86 c.writeText(xres / 10, yres / 6, xres * 4 / 7, yres / 6, RGB(255,255,255), RGB(0,0,0), gFont("Regular", 20),
87 _("If your TV has a brightness or contrast enhancement, disable it. If there is something called \"dynamic\", "
88 "set it to standard. Adjust the backlight level to a value suiting your taste. "
89 "Turn down contrast on your TV as much as possible.\nThen turn the brightness setting as "
90 "low as possible, but make sure that the two lowermost shades of gray stay distinguishable.\n"
91 "Do not care about the bright shades now. They will be set up in the next step.\n"
92 "If you are happy with the result, press OK."),
97 def testpic_contrast(self):
98 self.next = self.testpic_colors
102 xres, yres = 720, 576
104 bbw, bbh = xres / 192, yres / 192
105 c.fill(0, 0, xres, yres, RGB(0,0,0))
109 c.fill(0, 0, xres, yres, RGB(255,255,255))
111 # for i in range(15):
113 # width = xres - xres/5
115 # offset = xres/10 + ew * i
119 # c.fill(offset, y, ew, height, RGB(col, col, col))
121 # if col == 185 or col == 235 or col == 255:
122 # self.bbox(offset, y, ew, height, RGB(0,0,0), bbw, bbh)
125 # col = (7-i) * 255 / 7
129 offset = yres/6 + eh * i
133 c.fill(x, offset, width, eh, RGB(col, col, col))
134 # if col == 0 or col == 36:
135 # self.bbox(x, offset, width, eh, RGB(255,255,255), bbw, bbh);
137 # self.bbox(x, offset, width, eh, RGB(0,0,0), bbw, bbh);
138 if col == 185 or col == 235 or col == 255:
139 c.fill(x, offset, width, 2, RGB(0,0,0))
141 c.writeText(x + width, offset, width, eh, RGB(0, 0, 0), RGB(255, 255, 255), gFont("Regular", 20), "%d." % (i-13+1))
143 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,0,0), RGB(255,255,255), gFont("Regular", 40),
145 c.writeText(xres / 10, yres / 6, xres / 2, yres / 6, RGB(0,0,0), RGB(255,255,255), gFont("Regular", 20),
146 _("Now, use the contrast setting to turn up the brightness of the background as much as possible, "
147 "but make sure that you can still see the difference between the two brightest levels of shades."
148 "If you have done that, press OK."),
153 def testpic_colors(self):
154 self.next = self.close
158 xres, yres = 720, 576
162 c.fill(0, 0, xres, yres, RGB(255,255,255))
166 width = xres - xres/5;
168 offset = xres/10 + ew * i;
175 c2 = 0xFF - (0xFF * i / 16);
177 c1 = 0xFF - (0xFF * (i - 16) / 16);
180 c.fill(offset, y, ew, height, RGB(c1, c2, c2))
181 c.fill(offset, y + (height + o) * 1, ew, height, RGB(c2, c1, c2))
182 c.fill(offset, y + (height + o) * 2, ew, height, RGB(c2, c2, c1))
183 c.fill(offset, y + (height + o) * 3, ew, height, RGB(col, col, col))
186 self.bbox(offset, y, ew, height, RGB(0,0,0), bbw, bbh);
187 self.bbox(offset, y + (height + o) * 1, ew, height, RGB(0,0,0), bbw, bbh);
188 self.bbox(offset, y + (height + o) * 2, ew, height, RGB(0,0,0), bbw, bbh);
193 offset = yres/6 + eh * i;
197 c.fill(x, offset, width, eh, self.basic_colors[i])
199 self.bbox(x, offset, width, eh, RGB(0,0,0), bbw, bbh)
201 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,0,0), RGB(255,255,255), gFont("Regular", 40),
203 c.writeText(xres / 10, yres / 6, xres / 2, yres / 6, RGB(0,0,0), RGB(255,255,255), gFont("Regular", 20),
204 _("Adjust the color settings so that all the color shades are distinguishable, but appear as saturated as possible. "
205 "If you are happy with the result, press OK to close the video fine-tuning, or use the number keys to select other test screens."),
210 def testpic_filter(self):
213 xres, yres = 720, 576
215 c.fill(0, 0, xres, yres, RGB(64, 64, 64))
217 width = xres - xres/5
227 c.fill(offset - border, yb - border, border * 2 + width, border * 2 + (height * 3 + o * 2), RGB(g1, g1, g1))
229 for x in xrange(0, width, 2):
230 c.fill(offset + x, yb, 1, height, RGB(g2,g2,g2))
232 for x in xrange(0, width, 4):
233 c.fill(offset + x, yb + (o + height), 2, height, RGB(g2,g2,g2))
235 for x in xrange(0, width, 8):
236 c.fill(offset + x, yb + (o + height) * 2, 4, height, RGB(g2,g2,g2))
240 def testpic_gamma(self):
245 xres, yres = 720, 576
247 c.fill(0, 0, xres, yres, RGB(0, 0, 0))
249 width = xres - xres/5
252 height = yres - yres/5
255 for y in xrange(0, height, 4):
256 c.fill(offset_x, offset_y + y, width/2, 2, RGB(255,255,255))
259 fnt = gFont("Regular", height / 14)
261 for i in xrange(1, 15):
264 gamma = 0.6 + i * 0.2
265 col = int(math.pow(.5, 1.0/gamma) * 256.0)
266 c.fill(offset_x + width/2, offset_y + l, width/2, h, RGB(col,col,col))
268 c.writeText(offset_x + width/2, offset_y + l, width/2, h, RGB(0,0,0), RGB(col,col,col), fnt, "%1.2f" % gamma, RT_WRAP|RT_HALIGN_RIGHT)
273 def testpic_fubk(self):
277 # this test currently only works for 4:3 aspect.
278 # also it's hardcoded to 720,576
281 xres, yres = 720, 576
283 c.fill(0, 0, xres, yres, RGB(128, 128, 128))
285 for x in xrange(6, xres, 44):
286 c.fill(x, 0, 3, yres, RGB(255,255,255))
288 for y in xrange(34, yres, 44):
289 c.fill(0, y, xres, 3, RGB(255,255,255))
292 c.fill(140+i*55, 80, 55, 80, self.basic_colors[i])
294 c.fill(140+i*55, 160, 55, 80, RGB(g,g,g))
300 freq = (440 - x) / 44 + 1
302 col = RGB(255,255,255)
305 c.fill(140+x, 320, freq, 160, col)