diff --git a/src/lib/blit.c b/src/lib/blit.c index c39af1ddf..9acb502a9 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -216,6 +216,7 @@ static inline const char* quadrant_solver(uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br, uint32_t* fore, uint32_t* back){ const uint32_t colors[4] = { tl, tr, bl, br }; +//fprintf(stderr, "%08x/%08x/%08x/%08x\n", tl, tr, bl, br); uint32_t diffs[sizeof(quadrant_drivers) / sizeof(*quadrant_drivers)]; rgb_4diff(diffs, tl, tr, bl, br); // compiler can't verify that we'll always be less than 769 somewhere, @@ -238,26 +239,31 @@ quadrant_solver(uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br, // const uint32_t otherdiff = diffs[5 - mindiffidx]; *fore = lerp(colors[qd->pair[0]], colors[qd->pair[1]]); *back = lerp(colors[qd->others[0]], colors[qd->others[1]]); +//fprintf(stderr, "mindiff: %u[%zu] fore: %08x back: %08x %d+%d/%d+%d\n", mindiff, mindiffidx, *fore, *back, qd->pair[0], qd->pair[1], qd->others[0], qd->others[1]); const char* egc = qd->egc; // break down the excluded pair and lerp unsigned r0, r1, g0, g1, b0, b1; unsigned roth, goth, both, rlerp, glerp, blerp; - channel_rgb(qd->others[0], &r0, &g0, &b0); - channel_rgb(qd->others[1], &r1, &g1, &b1); + channel_rgb(colors[qd->others[0]], &r0, &g0, &b0); + channel_rgb(colors[qd->others[1]], &r1, &g1, &b1); channel_rgb(*fore, &rlerp, &glerp, &blerp); channel_rgb(*back, &roth, &goth, &both); +//fprintf(stderr, "rgbs: %02x %02x %02x / %02x %02x %02x\n", r0, g0, b0, r1, g1, b1); diffs[0] = rgb_diff(r0, g0, b0, rlerp, glerp, blerp); diffs[1] = rgb_diff(r0, g0, b0, roth, goth, both); diffs[2] = rgb_diff(r1, g1, b1, rlerp, glerp, blerp); diffs[3] = rgb_diff(r1, g1, b1, roth, goth, both); +//fprintf(stderr, "diffs: %08x %08x %08x %08x\n", diffs[0], diffs[1], diffs[2], diffs[3]); if(diffs[0] < diffs[1] && diffs[0] < diffs[2]){ egc = qd->oth0egc; *back = colors[qd->others[1]]; *fore = trilerp(colors[qd->pair[0]], colors[qd->pair[1]], colors[qd->others[0]]); +//fprintf(stderr, "swap 1 %08x %08x\n", *fore, *back); }else if(diffs[2] < diffs[3]){ egc = qd->oth1egc; *back = colors[qd->others[0]]; *fore = trilerp(colors[qd->pair[0]], colors[qd->pair[1]], colors[qd->others[1]]); +//fprintf(stderr, "swap 2 %08x %08x\n", *fore, *back); } return egc; } @@ -316,6 +322,7 @@ quadrant_blit(ncplane* nc, int placey, int placex, int linesize, uint32_t bg, fg; egc = quadrant_solver(tl, tr, bl, br, &fg, &bg); assert(egc); +//fprintf(stderr, "%d/%d %08x/%08x\n", y, x, fg, bg); cell_set_fchannel(c, fg); cell_set_bchannel(c, bg); if(blendcolors){ diff --git a/src/lib/fill.c b/src/lib/fill.c index dd8c30e75..924b3fbee 100644 --- a/src/lib/fill.c +++ b/src/lib/fill.c @@ -597,7 +597,7 @@ int ncplane_qrcode(ncplane* n, ncblitter_e blitter, int* ymax, if(rgba){ for(int y = starty ; y < starty + square ; ++y){ for(int x = startx ; x < startx + square ; ++x){ - const bool pixel = !qrcodegen_getModule(dst, x, y); + const bool pixel = qrcodegen_getModule(dst, x, y); ncpixel_set_a(&rgba[y * square + x], 0xff); ncpixel_set_rgb(&rgba[y * square + x], r * pixel, g * pixel, b * pixel); } diff --git a/src/poc/qrcode.c b/src/poc/qrcode.c index 2e4b2ba6d..f1020e79b 100644 --- a/src/poc/qrcode.c +++ b/src/poc/qrcode.c @@ -6,7 +6,7 @@ static int render_qrcode(struct ncplane* n, int dimy, int dimx, const char* text){ int y = dimy, x = dimx; ncplane_home(n); - int ver = ncplane_qrcode(n, NCBLIT_DEFAULT, &y, &x, text, strlen(text)); + int ver = ncplane_qrcode(n, NCBLIT_2x2, &y, &x, text, strlen(text)); if(ver < 0){ return -1; }