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))
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 == 36:
78 self.bbox(x, offset, width, eh, RGB(255,255,255), bbw, bbh)
80 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,255,255), RGB(0,0,0), gFont("Regular", 40),
82 c.writeText(xres / 10, yres / 6, xres * 4 / 7, yres / 6, RGB(255,255,255), RGB(0,0,0), gFont("Regular", 20),
83 _("If your TV has a brightness or contrast enhancement, disable it. If there is something called \"dynamic\", "
84 "set it to standard. Adjust the backlight level to a value suiting your taste. "
85 "Turn down contrast on your TV as much as possible.\nThen turn the brightness setting as "
86 "low as possible, but make sure that the two lowermost shades of gray stay distinguishable.\n"
87 "Do not care about the bright shades now. They will be set up in the next step.\n"
88 "If you are happy with the result, press OK."),
93 def testpic_contrast(self):
94 self.next = self.testpic_colors
100 bbw, bbh = xres / 192, yres / 192
101 c.fill(0, 0, xres, yres, RGB(0,0,0))
105 c.fill(0, 0, xres, yres, RGB(255,255,255))
109 width = xres - xres/5
111 offset = xres/10 + ew * i
115 c.fill(offset, y, ew, height, RGB(col, col, col))
117 if col == 185 or col == 235 or col == 255:
118 self.bbox(offset, y, ew, height, RGB(0,0,0), bbw, bbh)
121 col = (7-i) * 255 / 7
124 offset = yres/6 + eh * i
128 c.fill(x, offset, width, eh, RGB(col, col, col))
129 if col == 0 or col == 36:
130 self.bbox(x, offset, width, eh, RGB(255,255,255), bbw, bbh);
132 self.bbox(x, offset, width, eh, RGB(0,0,0), bbw, bbh);
134 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,0,0), RGB(255,255,255), gFont("Regular", 40),
136 c.writeText(xres / 10, yres / 6, xres / 2, yres / 6, RGB(0,0,0), RGB(255,255,255), gFont("Regular", 20),
137 _("Now, use the contrast setting to turn up the brightness of the background as much as possible, "
138 "but make sure that you can still see the difference between the two brightest levels of shades."
139 "If you have done that, press OK."),
144 def testpic_colors(self):
145 self.next = self.close
149 xres, yres = 720, 576
153 c.fill(0, 0, xres, yres, RGB(255,255,255))
157 width = xres - xres/5;
159 offset = xres/10 + ew * i;
166 c2 = 0xFF - (0xFF * i / 16);
168 c1 = 0xFF - (0xFF * (i - 16) / 16);
171 c.fill(offset, y, ew, height, RGB(c1, c2, c2))
172 c.fill(offset, y + (height + o) * 1, ew, height, RGB(c2, c1, c2))
173 c.fill(offset, y + (height + o) * 2, ew, height, RGB(c2, c2, c1))
174 c.fill(offset, y + (height + o) * 3, ew, height, RGB(col, col, col))
177 self.bbox(offset, y, ew, height, RGB(0,0,0), bbw, bbh);
178 self.bbox(offset, y + (height + o) * 1, ew, height, RGB(0,0,0), bbw, bbh);
179 self.bbox(offset, y + (height + o) * 2, ew, height, RGB(0,0,0), bbw, bbh);
184 offset = yres/6 + eh * i;
188 c.fill(x, offset, width, eh, self.basic_colors[i])
190 self.bbox(x, offset, width, eh, RGB(0,0,0), bbw, bbh)
192 c.writeText(xres / 10, yres / 6 - 40, xres * 3 / 5, 40, RGB(128,0,0), RGB(255,255,255), gFont("Regular", 40),
194 c.writeText(xres / 10, yres / 6, xres / 2, yres / 6, RGB(0,0,0), RGB(255,255,255), gFont("Regular", 20),
195 _("Adjust the color settings so that all the color shades are distinguishable, but appear as saturated as possible. "
196 "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."),
201 def testpic_filter(self):
204 xres, yres = 720, 576
206 c.fill(0, 0, xres, yres, RGB(64, 64, 64))
208 width = xres - xres/5
218 c.fill(offset - border, yb - border, border * 2 + width, border * 2 + (height * 3 + o * 2), RGB(g1, g1, g1))
220 for x in xrange(0, width, 2):
221 c.fill(offset + x, yb, 1, height, RGB(g2,g2,g2))
223 for x in xrange(0, width, 4):
224 c.fill(offset + x, yb + (o + height), 2, height, RGB(g2,g2,g2))
226 for x in xrange(0, width, 8):
227 c.fill(offset + x, yb + (o + height) * 2, 4, height, RGB(g2,g2,g2))
231 def testpic_gamma(self):
236 xres, yres = 720, 576
238 c.fill(0, 0, xres, yres, RGB(0, 0, 0))
240 width = xres - xres/5
243 height = yres - yres/5
246 for y in xrange(0, height, 4):
247 c.fill(offset_x, offset_y + y, width/2, 2, RGB(255,255,255))
250 fnt = gFont("Regular", height / 14)
252 for i in xrange(1, 15):
255 gamma = 0.6 + i * 0.2
256 col = int(math.pow(.5, 1.0/gamma) * 256.0)
257 c.fill(offset_x + width/2, offset_y + l, width/2, h, RGB(col,col,col))
259 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)
264 def testpic_fubk(self):
268 # this test currently only works for 4:3 aspect.
269 # also it's hardcoded to 720,576
272 xres, yres = 720, 576
274 c.fill(0, 0, xres, yres, RGB(128, 128, 128))
276 for x in xrange(6, xres, 44):
277 c.fill(x, 0, 3, yres, RGB(255,255,255))
279 for y in xrange(34, yres, 44):
280 c.fill(0, y, xres, 3, RGB(255,255,255))
283 c.fill(140+i*55, 80, 55, 80, self.basic_colors[i])
285 c.fill(140+i*55, 160, 55, 80, RGB(g,g,g))
291 freq = (440 - x) / 44 + 1
293 col = RGB(255,255,255)
296 c.fill(140+x, 320, freq, 160, col)