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_RIGHT, 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 "3": self.testpic_filter,
28 "4": self.testpic_gamma,
29 "5": 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
99 self.next = self.close
103 xres, yres = 720, 576
105 bbw, bbh = xres / 192, yres / 192
106 c.fill(0, 0, xres, yres, RGB(0,0,0))
110 c.fill(0, 0, xres, yres, RGB(255,255,255))
112 # for i in range(15):
114 # width = xres - xres/5
116 # offset = xres/10 + ew * i
120 # c.fill(offset, y, ew, height, RGB(col, col, col))
122 # if col == 185 or col == 235 or col == 255:
123 # self.bbox(offset, y, ew, height, RGB(0,0,0), bbw, bbh)
126 # col = (7-i) * 255 / 7
130 offset = yres/6 + eh * i
134 c.fill(x, offset, width, eh, RGB(col, col, col))
135 # if col == 0 or col == 36:
136 # self.bbox(x, offset, width, eh, RGB(255,255,255), bbw, bbh);
138 # self.bbox(x, offset, width, eh, RGB(0,0,0), bbw, bbh);
139 if col == 185 or col == 235 or col == 255:
140 c.fill(x, offset, width, 2, RGB(0,0,0))
142 c.writeText(x + width, offset, width, eh, RGB(0, 0, 0), RGB(255, 255, 255), gFont("Regular", 20), "%d." % (i-13+1))
144 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,0,0), RGB(255,255,255), gFont("Regular", 40),
146 c.writeText(xres / 10, yres / 6, xres / 2, yres / 6, RGB(0,0,0), RGB(255,255,255), gFont("Regular", 20),
147 _("Now, use the contrast setting to turn up the brightness of the background as much as possible, "
148 "but make sure that you can still see the difference between the two brightest levels of shades."
149 "If you have done that, press OK."),
154 def testpic_colors(self):
155 self.next = self.close
159 xres, yres = 720, 576
163 c.fill(0, 0, xres, yres, RGB(255,255,255))
167 width = xres - xres/5;
169 offset = xres/10 + ew * i;
176 c2 = 0xFF - (0xFF * i / 16);
178 c1 = 0xFF - (0xFF * (i - 16) / 16);
181 c.fill(offset, y, ew, height, RGB(c1, c2, c2))
182 c.fill(offset, y + (height + o) * 1, ew, height, RGB(c2, c1, c2))
183 c.fill(offset, y + (height + o) * 2, ew, height, RGB(c2, c2, c1))
184 c.fill(offset, y + (height + o) * 3, ew, height, RGB(col, col, col))
187 self.bbox(offset, y, ew, height, RGB(0,0,0), bbw, bbh);
188 self.bbox(offset, y + (height + o) * 1, ew, height, RGB(0,0,0), bbw, bbh);
189 self.bbox(offset, y + (height + o) * 2, ew, height, RGB(0,0,0), bbw, bbh);
194 offset = yres/6 + eh * i;
198 c.fill(x, offset, width, eh, self.basic_colors[i])
200 self.bbox(x, offset, width, eh, RGB(0,0,0), bbw, bbh)
202 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,0,0), RGB(255,255,255), gFont("Regular", 40),
204 c.writeText(xres / 10, yres / 6, xres / 2, yres / 6, RGB(0,0,0), RGB(255,255,255), gFont("Regular", 20),
205 _("Adjust the color settings so that all the color shades are distinguishable, but appear as saturated as possible. "
206 "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."),
211 def testpic_filter(self):
214 xres, yres = 720, 576
216 c.fill(0, 0, xres, yres, RGB(64, 64, 64))
218 width = xres - xres/5
228 c.fill(offset - border, yb - border, border * 2 + width, border * 2 + (height * 3 + o * 2), RGB(g1, g1, g1))
230 for x in xrange(0, width, 2):
231 c.fill(offset + x, yb, 1, height, RGB(g2,g2,g2))
233 for x in xrange(0, width, 4):
234 c.fill(offset + x, yb + (o + height), 2, height, RGB(g2,g2,g2))
236 for x in xrange(0, width, 8):
237 c.fill(offset + x, yb + (o + height) * 2, 4, height, RGB(g2,g2,g2))
241 def testpic_gamma(self):
246 xres, yres = 720, 576
248 c.fill(0, 0, xres, yres, RGB(0, 0, 0))
250 width = xres - xres/5
253 height = yres - yres/5
256 for y in xrange(0, height, 4):
257 c.fill(offset_x, offset_y + y, width/2, 2, RGB(255,255,255))
260 fnt = gFont("Regular", height / 14)
262 for i in xrange(1, 15):
265 gamma = 0.6 + i * 0.2
266 col = int(math.pow(.5, 1.0/gamma) * 256.0)
267 c.fill(offset_x + width/2, offset_y + l, width/2, h, RGB(col,col,col))
269 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)
274 def testpic_fubk(self):
278 # this test currently only works for 4:3 aspect.
279 # also it's hardcoded to 720,576
282 xres, yres = 720, 576
284 c.fill(0, 0, xres, yres, RGB(128, 128, 128))
286 for x in xrange(6, xres, 44):
287 c.fill(x, 0, 3, yres, RGB(255,255,255))
289 for y in xrange(34, yres, 44):
290 c.fill(0, y, xres, 3, RGB(255,255,255))
293 c.fill(140+i*55, 80, 55, 80, self.basic_colors[i])
295 c.fill(140+i*55, 160, 55, 80, RGB(g,g,g))
301 freq = (440 - x) / 44 + 1
303 col = RGB(255,255,255)
306 c.fill(140+x, 320, freq, 160, col)