diff --git a/.travis.yml b/.travis.yml index 646202f19..6b26b9cbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ before_install: - if [ "$QT_BASE" = "57" ]; then sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y; fi - sudo apt-get update -qq - pyenv uninstall -f 2.7.6 && pyenv install 3.5.4 && pyenv global 3.5.4 - - pip install pyqt5 + - pip install pillow install: - sudo apt-get --yes --force-yes install curl libmpfr4 libmpc3 libfox-1.6-dev libgtest-dev diff --git a/radio/src/fonts/480x272/font_dblsize.png b/radio/src/fonts/480x272/font_dblsize.png index dd57cba93..174c70f9b 100644 Binary files a/radio/src/fonts/480x272/font_dblsize.png and b/radio/src/fonts/480x272/font_dblsize.png differ diff --git a/radio/src/fonts/480x272/font_dblsize.specs b/radio/src/fonts/480x272/font_dblsize.specs index 3c05e7a26..07d83c610 100644 --- a/radio/src/fonts/480x272/font_dblsize.specs +++ b/radio/src/fonts/480x272/font_dblsize.specs @@ -1 +1 @@ -0,4,14,25,45,64,89,111,117,129,141,157,175,184,197,207,220,239,258,277,296,315,334,353,372,391,410,420,429,446,465,483,500,513,536,557,579,601,620,639,662,686,696,715,737,755,784,808,831,853,876,897,918,939,961,983,1012,1033,1054,1074,1084,1100,1110,1125,1141,1153,1171,1190,1208,1227,1245,1258,1277,1296,1305,1314,1333,1342,1371,1390,1409,1428,1447,1460,1477,1489,1508,1525,1550,1568,1585,1602,1624,1633,1651,1664,1677,1690,1703,1716,1729,1742,1755,1768,1783,1798,1813,1828,1843,1858,1873,1888,1903,1918,1933,1948,1966,1984,2002,2014,2032,2055,2073,2096,2115,2137,2156,2177,2195,2212,2230,2244,2261,2278,2296,2308,2326,2345,2364,2383,2402,2426,2441,2460,2481,2503,2524,2544,2565,2588,2600,2619,2643,2666,2688,2710,2732,2753,2777,2796,2814,2832,2851,2874,2897,2920,2938,2957,2975,2993,3011,3022,3041,3060,3077,3094,3111,3134,3156,3175,3194,3218,3241,3262,3282,3302,3320,3338,3357,3380,3403,3426 \ No newline at end of file +0,4,14,25,45,64,89,111,117,129,141,157,175,184,197,207,220,239,258,277,296,315,334,353,372,391,410,420,429,446,465,483,500,513,536,557,579,601,620,639,662,686,696,715,737,755,784,808,831,853,876,897,918,939,961,983,1012,1033,1054,1074,1084,1100,1110,1125,1141,1153,1171,1190,1208,1227,1245,1258,1277,1296,1305,1314,1333,1342,1371,1390,1409,1428,1447,1460,1477,1489,1508,1525,1550,1568,1585,1602,1624,1633,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1651,1669,1687,1705,1717,1735,1758,1776,1799,1818,1840,1859,1880,1898,1915,1933,1947,1964,1981,1999,2011,2029,2048,2067,2086,2105,2129,2144,2163,2184,2206,2227,2247,2268,2291,2303,2322,2346,2369,2391,2413,2435,2456,2480,2499,2517,2535,2554,2577,2600,2623,2641,2660,2678,2696,2714,2725,2744,2763,2780,2797,2814,2837,2859,2878,2897,2921,2944,2965,2985,3005,3023,3041,3060,3083,3106,3129 \ No newline at end of file diff --git a/radio/src/fonts/480x272/font_midsize.png b/radio/src/fonts/480x272/font_midsize.png index ff92c0a32..3391516af 100644 Binary files a/radio/src/fonts/480x272/font_midsize.png and b/radio/src/fonts/480x272/font_midsize.png differ diff --git a/radio/src/fonts/480x272/font_midsize.specs b/radio/src/fonts/480x272/font_midsize.specs index 590671d05..9e98f5af3 100644 --- a/radio/src/fonts/480x272/font_midsize.specs +++ b/radio/src/fonts/480x272/font_midsize.specs @@ -1 +1 @@ -0,4,11,20,36,50,69,85,90,99,108,119,134,140,148,155,166,180,194,208,222,236,250,264,278,292,306,313,319,332,346,360,372,382,399,415,432,449,464,478,495,513,521,535,552,566,588,606,624,640,658,674,689,704,721,737,759,775,791,806,814,825,832,843,855,863,877,891,905,920,934,944,958,972,979,986,1000,1007,1029,1043,1058,1072,1087,1096,1109,1118,1132,1145,1164,1177,1189,1202,1219,1226,1240,1253,1266,1279,1292,1305,1318,1331,1344,1357,1372,1387,1402,1417,1432,1447,1462,1477,1492,1507,1522,1537,1551,1565,1579,1587,1601,1618,1632,1650,1665,1682,1696,1711,1725,1738,1752,1762,1775,1787,1801,1809,1823,1837,1852,1866,1880,1896,1906,1921,1936,1953,1969,1984,2000,2017,2026,2041,2059,2077,2094,2111,2128,2143,2161,2175,2189,2203,2218,2235,2252,2270,2284,2298,2312,2326,2340,2348,2362,2377,2390,2403,2416,2433,2450,2465,2479,2497,2515,2530,2545,2560,2574,2588,2603,2620,2637,2655 \ No newline at end of file +0,4,11,20,36,50,69,85,90,99,108,119,134,140,148,155,166,180,194,208,222,236,250,264,278,292,306,313,319,332,346,360,372,382,399,415,432,449,464,478,495,513,521,535,552,566,588,606,624,640,658,674,689,704,721,737,759,775,791,806,814,825,832,843,855,863,877,891,905,920,934,944,958,972,979,986,1000,1007,1029,1043,1058,1072,1087,1096,1109,1118,1132,1145,1164,1177,1189,1202,1219,1226,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1240,1254,1268,1282,1290,1304,1321,1335,1353,1368,1385,1399,1414,1428,1441,1455,1465,1478,1490,1504,1512,1526,1540,1555,1569,1583,1599,1609,1624,1639,1656,1672,1687,1703,1720,1729,1744,1762,1780,1797,1814,1831,1846,1864,1878,1892,1906,1921,1938,1955,1973,1987,2001,2015,2029,2043,2051,2065,2080,2093,2106,2119,2136,2153,2168,2182,2200,2218,2233,2248,2263,2277,2291,2306,2323,2340,2358 \ No newline at end of file diff --git a/radio/src/fonts/480x272/font_smlsize.png b/radio/src/fonts/480x272/font_smlsize.png index db992ce9b..30aef1915 100644 Binary files a/radio/src/fonts/480x272/font_smlsize.png and b/radio/src/fonts/480x272/font_smlsize.png differ diff --git a/radio/src/fonts/480x272/font_smlsize.specs b/radio/src/fonts/480x272/font_smlsize.specs index c4f516306..8802a9945 100644 --- a/radio/src/fonts/480x272/font_smlsize.specs +++ b/radio/src/fonts/480x272/font_smlsize.specs @@ -1 +1 @@ -0,4,8,13,22,30,41,51,54,60,66,73,81,85,90,94,100,108,116,124,132,141,149,157,165,173,181,185,189,197,205,213,220,226,236,245,254,264,272,280,290,300,305,313,323,331,343,353,363,372,382,391,400,409,418,427,440,449,458,467,472,479,483,489,496,501,509,517,525,533,541,547,555,563,567,571,579,583,595,603,611,619,627,633,641,646,654,661,672,680,687,695,705,709,717,730,743,756,769,782,795,808,821,834,849,864,879,894,909,924,939,954,969,984,999,1014,1022,1030,1038,1043,1051,1061,1069,1079,1087,1096,1104,1113,1121,1129,1137,1143,1151,1158,1166,1171,1179,1187,1195,1203,1211,1221,1228,1236,1245,1254,1263,1272,1281,1291,1296,1304,1314,1324,1333,1342,1352,1361,1371,1379,1387,1395,1403,1413,1423,1433,1441,1449,1457,1465,1473,1478,1486,1494,1502,1510,1518,1528,1537,1545,1553,1563,1573,1582,1591,1600,1608,1616,1624,1634,1644,1654 \ No newline at end of file +0,4,8,13,22,30,41,51,54,60,66,73,81,85,90,94,100,108,116,124,132,141,149,157,165,173,181,185,189,197,205,213,220,226,236,245,254,264,272,280,290,300,305,313,323,331,343,353,363,372,382,391,400,409,418,427,440,449,458,467,472,479,483,489,496,501,509,517,525,533,541,547,555,563,567,571,579,583,595,603,611,619,627,633,641,646,654,661,672,680,687,695,705,709,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,725,733,741,746,754,764,772,782,790,799,807,816,824,832,840,846,854,861,869,874,882,890,898,906,914,924,931,939,948,957,966,975,984,994,999,1007,1017,1027,1036,1045,1055,1064,1074,1082,1090,1098,1106,1116,1126,1136,1144,1152,1160,1168,1176,1181,1189,1197,1205,1213,1221,1231,1240,1248,1256,1266,1276,1285,1294,1303,1311,1319,1327,1337,1347,1357 \ No newline at end of file diff --git a/radio/src/fonts/480x272/font_stdsize.png b/radio/src/fonts/480x272/font_stdsize.png index bda4cb4c4..48646859e 100644 Binary files a/radio/src/fonts/480x272/font_stdsize.png and b/radio/src/fonts/480x272/font_stdsize.png differ diff --git a/radio/src/fonts/480x272/font_stdsizebold.png b/radio/src/fonts/480x272/font_stdsizebold.png index f1b41e5a6..5dfd2a49b 100644 Binary files a/radio/src/fonts/480x272/font_stdsizebold.png and b/radio/src/fonts/480x272/font_stdsizebold.png differ diff --git a/radio/src/fonts/480x272/font_tinsize.png b/radio/src/fonts/480x272/font_tinsize.png index 2fb268e18..66a09bd54 100644 Binary files a/radio/src/fonts/480x272/font_tinsize.png and b/radio/src/fonts/480x272/font_tinsize.png differ diff --git a/radio/src/fonts/480x272/font_tinsize.specs b/radio/src/fonts/480x272/font_tinsize.specs index 7c0e20a69..1f6806bfc 100644 --- a/radio/src/fonts/480x272/font_tinsize.specs +++ b/radio/src/fonts/480x272/font_tinsize.specs @@ -1 +1 @@ -0,4,7,11,18,24,32,39,42,46,50,55,61,64,68,71,76,82,88,94,100,106,112,118,124,130,136,139,142,148,154,160,165,169,176,183,190,197,203,209,216,223,226,232,239,245,254,261,268,275,282,289,295,302,309,316,325,332,339,346,350,355,358,363,369,373,379,385,391,397,403,408,414,420,423,426,432,435,444,450,456,462,468,472,478,482,488,493,501,507,513,519,526,529,535,548,561,574,587,600,613,626,639,652,667,682,697,712,727,742,757,772,787,802,817,832,838,844,850,854,860,867,873,880,886,893,899,905,911,917,923,928,934,940,946,950,956,962,968,974,980,987,992,998,1004,1011,1018,1025,1032,1039,1043,1049,1056,1063,1070,1077,1084,1091,1098,1104,1110,1116,1122,1129,1136,1143,1149,1155,1161,1167,1173,1177,1183,1189,1195,1201,1207,1214,1221,1227,1233,1240,1247,1253,1260,1267,1273,1279,1285,1292,1299,1306 \ No newline at end of file +0,4,7,11,18,24,32,39,42,46,50,55,61,64,68,71,76,82,88,94,100,106,112,118,124,130,136,139,142,148,154,160,165,169,176,183,190,197,203,209,216,223,226,232,239,245,254,261,268,275,282,289,295,302,309,316,325,332,339,346,350,355,358,363,369,373,379,385,391,397,403,408,414,420,423,426,432,435,444,450,456,462,468,472,478,482,488,493,501,507,513,519,526,529,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,541,547,553,557,563,570,576,583,589,596,602,608,614,620,626,631,637,643,649,653,659,665,671,677,683,690,695,701,707,714,721,728,735,742,746,752,759,766,773,780,787,794,801,807,813,819,825,832,839,846,852,858,864,870,876,880,886,892,898,904,910,917,924,930,936,943,950,956,963,970,976,982,988,995,1002,1009 \ No newline at end of file diff --git a/radio/src/fonts/480x272/font_xxlsize.png b/radio/src/fonts/480x272/font_xxlsize.png index 3573e5e64..c9a16dfe4 100644 Binary files a/radio/src/fonts/480x272/font_xxlsize.png and b/radio/src/fonts/480x272/font_xxlsize.png differ diff --git a/radio/src/fonts/480x272/font_xxlsize.specs b/radio/src/fonts/480x272/font_xxlsize.specs index 2217438ec..ac4d4eb30 100644 --- a/radio/src/fonts/480x272/font_xxlsize.specs +++ b/radio/src/fonts/480x272/font_xxlsize.specs @@ -1 +1 @@ -0,4,22,44,83,121,169,212,223,246,270,300,336,353,379,399,424,462,500,538,576,614,652,690,728,766,804,823,841,875,913,947,980,1006,1050,1092,1135,1178,1215,1251,1296,1342,1362,1399,1442,1478,1535,1581,1626,1668,1713,1755,1795,1836,1879,1922,1979,2021,2062,2102,2121,2151,2170,2199,2229,2251,2286,2323,2357,2394,2430,2454,2492,2529,2547,2565,2601,2619,2675,2712,2749,2786,2823,2847,2881,2904,2941,2974,3022,3056,3089,3123,3166,3183,3217,3230,3243,3256,3269,3282,3295,3308,3321,3334,3349,3364,3379,3394,3409,3424,3439,3454,3469,3484,3499,3514,3550,3586,3621,3643,3677,3721,3756,3801,3838,3881,3918,3959,3995,4029,4063,4090,4124,4157,4192,4214,4250,4287,4324,4361,4398,4443,4471,4508,4548,4591,4633,4673,4714,4758,4781,4818,4864,4909,4952,4995,5038,5079,5125,5162,5197,5232,5269,5313,5357,5402,5437,5474,5509,5543,5579,5600,5637,5674,5708,5742,5776,5820,5863,5900,5937,5983,6028,6068,6108,6148,6183,6218,6255,6299,6343,6388 \ No newline at end of file +0,4,22,44,83,121,169,212,223,246,270,300,336,353,379,399,424,462,500,538,576,614,652,690,728,766,804,823,841,875,913,947,980,1006,1050,1092,1135,1178,1215,1251,1296,1342,1362,1399,1442,1478,1535,1581,1626,1668,1713,1755,1795,1836,1879,1922,1979,2021,2062,2102,2121,2151,2170,2199,2229,2251,2286,2323,2357,2394,2430,2454,2492,2529,2547,2565,2601,2619,2675,2712,2749,2786,2823,2847,2881,2904,2941,2974,3022,3056,3089,3123,3166,3183,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3217,3253,3289,3324,3346,3380,3424,3459,3504,3541,3584,3621,3662,3698,3732,3766,3793,3827,3860,3895,3917,3953,3990,4027,4064,4101,4146,4174,4211,4251,4294,4336,4376,4417,4461,4484,4521,4567,4612,4655,4698,4741,4782,4828,4865,4900,4935,4972,5016,5060,5105,5140,5177,5212,5246,5282,5303,5340,5377,5411,5445,5479,5523,5566,5603,5640,5686,5731,5771,5811,5851,5886,5921,5958,6002,6046,6091 \ No newline at end of file diff --git a/radio/src/tests/fonts_480x272.png b/radio/src/tests/fonts_480x272.png index cc63cc91e..da2ac09d3 100644 Binary files a/radio/src/tests/fonts_480x272.png and b/radio/src/tests/fonts_480x272.png differ diff --git a/radio/src/tests/primitives_480x272.png b/radio/src/tests/primitives_480x272.png index 60b976cad..ae3f0b94f 100644 Binary files a/radio/src/tests/primitives_480x272.png and b/radio/src/tests/primitives_480x272.png differ diff --git a/radio/src/tests/transparency_480x272.png b/radio/src/tests/transparency_480x272.png index 3251b0b0a..b8fec6660 100644 Binary files a/radio/src/tests/transparency_480x272.png and b/radio/src/tests/transparency_480x272.png differ diff --git a/radio/util/Dockerfile b/radio/util/Dockerfile index e8fbf6629..a5a49a64a 100644 --- a/radio/util/Dockerfile +++ b/radio/util/Dockerfile @@ -1,11 +1,11 @@ # An Debian image for compiling OpenTX 2.2 -FROM debian:jessie +FROM debian:stretch RUN DEBIAN_FRONTEND=noninteractive apt-get -y update RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake gcc git lib32ncurses5 lib32z1 libfox-1.6-dev libsdl1.2-dev \ - python-qt4 qt5-default qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5svg5-dev \ - software-properties-common wget zip python-pip python-pil + qt5-default qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5svg5-dev \ + software-properties-common wget zip python-pip python-pil libgtest-dev RUN python -m pip install filelock diff --git a/radio/util/font2png.py b/radio/util/font2png.py index de8e5c939..86d0f9c40 100755 --- a/radio/util/font2png.py +++ b/radio/util/font2png.py @@ -33,25 +33,26 @@ def createFontBitmap(filename, fontname, fontsize, fontoffset, foreground, backg font = ImageFont.truetype(font_filename, fontsize) extraImage = None - extraWidth, extraHeight = 0, 0 extraFilename = 'fonts/extra_%dpx.png' % fontsize try: extraImage = Image.open(extraFilename) extraImage = extraImage.convert('RGB'); - extraWidth, extraHeight = extraImage.size - - extraWidth = extraWidth / COUNT_EXTRA_CHARS except IOError: print 'Missing extra symbol filename %s' % extraFilename def getCharWidth(c): if c in chars_extra: - if ord(c) <= 9: - return 13 + if extraImage: + # Extra characters 16px + #if fontsize == 16: + if ord(c) <= 9: + return 13 + else: + return 15 else: - return 15 + return 0 elif c == " ": return 4 else: diff --git a/radio/util/img2lbm.py b/radio/util/img2lbm.py index 44db758bd..341502e00 100755 --- a/radio/util/img2lbm.py +++ b/radio/util/img2lbm.py @@ -3,14 +3,12 @@ from __future__ import division, print_function import sys -try: - from PyQt5 import Qt, QtGui -except: - from PyQt4 import Qt, QtGui +from PIL import Image -image = QtGui.QImage(sys.argv[1]) -width, height = image.size().width(), image.size().height() +image = Image.open(sys.argv[1]) +width, height = image.size +image_fmt = image.format def writeSize(f, width, height): if lcdwidth > 255: @@ -34,13 +32,19 @@ with open(sys.argv[2], "w") as f: rows = 1 if len(sys.argv) > 5: rows = int(sys.argv[5]) + image = image.convert(mode='1') writeSize(f, width, height // rows) for y in range(0, height, 8): for x in range(width): value = 0 for z in range(8): - if y + z < height and image.pixel(x, y + z) == Qt.qRgb(0, 0, 0): - value += 1 << z + if y + z < height: + if image_fmt == 'XBM': + if image.getpixel((x, y + z)) > 0: + value += 1 << z + else: + if image.getpixel((x, y + z)) == 0: + value += 1 << z f.write("0x%02x," % value) f.write("\n") elif what == "4/4/4/4": @@ -48,8 +52,8 @@ with open(sys.argv[2], "w") as f: values = [] for y in range(height): for x in range(width): - pixel = image.pixel(x, y) - val = ((Qt.qAlpha(pixel) // 16) << 12) + ((Qt.qRed(pixel) // 16) << 8) + ((Qt.qGreen(pixel) // 16) << 4) + ((Qt.qBlue(pixel) // 16) << 0) + pixel = image.getpixel((x, y)) + val = ((pixel[3] // 16) << 12) + ((pixel[0] // 16) << 8) + ((pixel[1] // 16) << 4) + ((pixel[2] // 16) << 0) values.append(str(val)) f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values))) f.write("const Bitmap %s(BMP_ARGB4444, %d, %d, __%s);\n" % (constant, width, height, constant)) @@ -58,8 +62,8 @@ with open(sys.argv[2], "w") as f: values = [] for y in range(height): for x in range(width): - pixel = image.pixel(width-x-1, height-y-1) - val = ((Qt.qAlpha(pixel) // 16) << 12) + ((Qt.qRed(pixel) // 16) << 8) + ((Qt.qGreen(pixel) // 16) << 4) + ((Qt.qBlue(pixel) // 16) << 0) + pixel = image.getpixel((width-x-1, height-y-1)) + val = ((pixel[3] // 16) << 12) + ((pixel[0] // 16) << 8) + ((pixel[1] // 16) << 4) + ((pixel[2] // 16) << 0) values.append(str(val)) f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values))) f.write("const Bitmap %s(BMP_ARGB4444, %d, %d, __%s);\n" % (constant, width, height, constant)) @@ -68,8 +72,8 @@ with open(sys.argv[2], "w") as f: values = [] for y in range(height): for x in range(width): - pixel = image.pixel(x, y) - val = ((Qt.qRed(pixel) >> 3) << 11) + ((Qt.qGreen(pixel) >> 2) << 5) + ((Qt.qBlue(pixel) >> 3) << 0) + pixel = image.getpixel((x, y)) + val = ((pixel[0] >> 3) << 11) + ((pixel[1] >> 2) << 5) + ((pixel[2] >> 3) << 0) values.append(str(val)) f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values))) f.write("const Bitmap %s(BMP_RGB565, %d, %d, __%s);\n" % (constant, width, height, constant)) @@ -78,31 +82,32 @@ with open(sys.argv[2], "w") as f: values = [] for y in range(height): for x in range(width): - pixel = image.pixel(width-x-1, height-y-1) - val = ((Qt.qRed(pixel) >> 3) << 11) + ((Qt.qGreen(pixel) >> 2) << 5) + ((Qt.qBlue(pixel) >> 3) << 0) + pixel = image.getpixel((width-x-1, height-y-1)) + val = ((pixel[0] >> 3) << 11) + ((pixel[1] >> 2) << 5) + ((pixel[2] >> 3) << 0) values.append(str(val)) f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values))) f.write("const Bitmap %s(BMP_RGB565, %d, %d, __%s);\n" % (constant, width, height, constant)) - elif what == "5/6/5/8": - colors = [] - writeSize(f, width, height) - for y in range(height): - for x in range(width): - pixel = image.pixel(x, y) - val = ((Qt.qRed(pixel) >> 4) << 12) + ((Qt.qGreen(pixel) >> 4) << 7) + ((Qt.qBlue(pixel) >> 4) << 1) - f.write("%d,%d,%d," % (val % 256, val // 256, Qt.qAlpha(pixel))) - f.write("\n") + # elif what == "5/6/5/8": + # colors = [] + # writeSize(f, width, height) + # for y in range(height): + # for x in range(width): + # pixel = image.pixel(x, y) + # val = ((Qt.qRed(pixel) >> 4) << 12) + ((Qt.qGreen(pixel) >> 4) << 7) + ((Qt.qBlue(pixel) >> 4) << 1) + # f.write("%d,%d,%d," % (val % 256, val // 256, Qt.qAlpha(pixel))) + # f.write("\n") elif what == "4bits": colors = [] writeSize(f, width, height) + image = image.convert(mode='L') for y in range(0, height, 2): for x in range(width): value = 0xFF - gray1 = Qt.qGray(image.pixel(x, y)) + gray1 = image.getpixel((x, y)) if y + 1 < height: - gray2 = Qt.qGray(image.pixel(x, y + 1)) + gray2 = image.getpixel((x, y + 1)) else: - gray2 = Qt.qRgb(255, 255, 255) + gray2 = 255 for i in range(4): if (gray1 & (1 << (4 + i))): value -= 1 << i @@ -113,42 +118,47 @@ with open(sys.argv[2], "w") as f: elif what == "8bits": colors = [] writeSize(f, width, height) + image = image.convert(mode='L') for y in range(height): for x in range(width): - value = Qt.qGray(image.pixel(x, y)) + value = image.getpixel((x, y)) value = 0x0f - (value >> 4) f.write("0x%02x," % value) f.write("\n") elif what == "03x05": + image = image.convert(mode='L') for y in range(0, height, 5): for x in range(width): value = 0 for z in range(5): - if image.pixel(x, y + z) == Qt.qRgb(0, 0, 0): + if image.getpixel((x, y + z)) == 0: value += 1 << z f.write("0x%02x," % value) f.write("\n") elif what == "04x06": + image = image.convert(mode='L') for y in range(0, height, 7): for x in range(width): value = 0 for z in range(7): - if image.pixel(x, y + z) == Qt.qRgb(0, 0, 0): + if image.getpixel((x, y + z)) == 0: value += 1 << z if value == 0x7f: value = 0xff f.write("0x%02x," % value) f.write("\n") elif what == "05x07": + image = image.convert(mode='L') for y in range(0, height, 8): for x in range(width): value = 0 for z in range(8): - if image.pixel(x, y + z) == Qt.qRgb(0, 0, 0): + if image.getpixel((x, y + z)) == 0: value += 1 << z f.write("0x%02x," % value) f.write("\n") elif what == "08x10": + image = image.convert(mode='L') for y in range(0, height, 12): for x in range(width): skip = True @@ -156,31 +166,34 @@ with open(sys.argv[2], "w") as f: value = 0 for z in range(8): if l + z < 12: - if image.pixel(x, y + l + z) == Qt.qRgb(0, 0, 0): + if image.getpixel((x, y + l + z)) == 0: value += 1 << z else: skip = False if skip and l == 8: value = 0xff f.write("0x%02x," % value) + #print ("0x%02x (%d,%d,%d)" % (value,x,y,l)) f.write("\n") elif what == "10x14": + image = image.convert(mode='L') for y in range(0, height, 16): for x in range(width): for l in range(0, 16, 8): value = 0 for z in range(8): - if image.pixel(x, y + l + z) == Qt.qRgb(0, 0, 0): + if image.getpixel((x, y + l + z)) == 0: value += 1 << z f.write("0x%02x," % value) f.write("\n") elif what == "22x38": + image = image.convert(mode='L') for y in range(0, height, 40): for x in range(width): for l in range(0, 40, 8): value = 0 for z in range(8): - if image.pixel(x, y + l + z) == Qt.qRgb(0, 0, 0): + if image.getpixel((x, y + l + z)) == 0: value += 1 << z f.write("0x%02x," % value) f.write("\n")