| 587 | } |
| 588 | |
| 589 | void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { |
| 590 | char buf[256]; |
| 591 | cc_string str; |
| 592 | int len; |
| 593 | String_InitArray(str, buf); |
| 594 | |
| 595 | for (int y = r.y & ~0x01; y < r.y + r.height; y += 2) |
| 596 | { |
| 597 | //len = sprintf(buf, CSI "%i;%iH", y / 2, r.x); // move cursor to start |
| 598 | //OutputConsole(buf, len); |
| 599 | str.length = 0; |
| 600 | String_AppendConst(&str, CSI); |
| 601 | String_AppendInt( &str, y / CHARS_PER_CELL); |
| 602 | String_Append( &str, ';'); |
| 603 | String_AppendInt( &str, r.x); |
| 604 | String_Append( &str, 'H'); |
| 605 | OutputConsole(buf, str.length); |
| 606 | |
| 607 | for (int x = r.x; x < r.x + r.width; x++) |
| 608 | { |
| 609 | BitmapCol top = Bitmap_GetPixel(bmp, x, y + 0); |
| 610 | BitmapCol bot = Bitmap_GetPixel(bmp, x, y + 1); |
| 611 | |
| 612 | // Use '▄' so each cell can use a background and foreground colour |
| 613 | // This essentially doubles the vertical resolution of the displayed image |
| 614 | //printf(CSI "48;2;%i;%i;%im", BitmapCol_R(top), BitmapCol_G(top), BitmapCol_B(top)); |
| 615 | //printf(CSI "38;2;%i;%i;%im", BitmapCol_R(bot), BitmapCol_G(bot), BitmapCol_B(bot)); |
| 616 | //printf("\xE2\x96\x84"); |
| 617 | //len = sprintf(buf, CSI "48;2;%i;%i;%im" CSI "38;2;%i;%i;%im" BOX_CHAR, |
| 618 | // BitmapCol_R(top), BitmapCol_G(top), BitmapCol_B(top), |
| 619 | // BitmapCol_R(bot), BitmapCol_G(bot), BitmapCol_B(bot)); |
| 620 | |
| 621 | // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors |
| 622 | str.length = 0; |
| 623 | if (supportsTruecolor) { |
| 624 | String_AppendConst(&str, CSI "48" SEP_STR "2" SEP_STR); |
| 625 | String_AppendInt( &str, BitmapCol_R(top)); |
| 626 | String_Append( &str, SEP_CHAR); |
| 627 | String_AppendInt( &str, BitmapCol_G(top)); |
| 628 | String_Append( &str, SEP_CHAR); |
| 629 | String_AppendInt( &str, BitmapCol_B(top)); |
| 630 | String_Append( &str, 'm'); |
| 631 | |
| 632 | String_AppendConst(&str, CSI "38" SEP_STR "2" SEP_STR); |
| 633 | String_AppendInt( &str, BitmapCol_R(bot)); |
| 634 | String_Append( &str, SEP_CHAR); |
| 635 | String_AppendInt( &str, BitmapCol_G(bot)); |
| 636 | String_Append( &str, SEP_CHAR); |
| 637 | String_AppendInt( &str, BitmapCol_B(bot)); |
| 638 | String_Append( &str, 'm'); |
| 639 | } else { |
| 640 | String_AppendConst(&str, CSI "48" SEP_STR "5" SEP_STR); |
| 641 | String_AppendInt( &str, CalcIndex(top)); |
| 642 | String_Append( &str, 'm'); |
| 643 | |
| 644 | String_AppendConst(&str, CSI "38" SEP_STR "5" SEP_STR); |
| 645 | String_AppendInt( &str, CalcIndex(bot)); |
| 646 | String_Append( &str, 'm'); |
nothing calls this directly
no test coverage detected