Changeset 378
 Timestamp:
 Nov 5, 2004, 3:57:50 PM (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libcaca/trunk/src/bitmap.c
r376 r378 569 569 { 570 570 int remain_r = 0, remain_g = 0, remain_b = 0; 571 int remain_r_next = 0, remain_g_next = 0, remain_b_next = 0;572 571 573 572 for(x = x1 > 0 ? x1 : 0, _init_dither(y); … … 579 578 int r, g, b, a, fg_r = 0, fg_g = 0, fg_b = 0, bg_r, bg_g, bg_b; 580 579 int fromx, fromy, tox, toy, myx, myy, dots, dist; 580 int error[3]; 581 581 582 582 enum caca_color outfg = 0, outbg = 0; … … 642 642 g += remain_g; 643 643 b += remain_b; 644 r += remain_r_next;645 g += remain_g_next;646 b += remain_b_next;647 remain_r_next = fs_r[x+1];648 remain_g_next = fs_g[x+1];649 remain_b_next = fs_b[x+1];650 644 } 651 645 else … … 711 705 } 712 706 outch = density_chars[4 * ch]; 707 708 if(_caca_dithering == CACA_DITHERING_FSTEIN) 709 { 710 error[0] = r  (fg_r * ch + bg_r * ((2*DCHMAX1)  ch)) / (2*DCHMAX1); 711 error[1] = g  (fg_g * ch + bg_g * ((2*DCHMAX1)  ch)) / (2*DCHMAX1); 712 error[2] = b  (fg_b * ch + bg_b * ((2*DCHMAX1)  ch)) / (2*DCHMAX1); 713 } 713 714 } 714 715 else 715 716 { 716 int lum = r; 717 if(g > lum) 718 lum = g; 719 if(b > lum) 720 lum = b; 717 int lum = r; if(g > lum) lum = g; if(b > lum) lum = b; 721 718 outfg = outbg; 722 719 outbg = CACA_COLOR_BLACK; … … 728 725 ch = DCHMAX  1; 729 726 outch = density_chars[4 * ch]; 727 728 if(_caca_dithering == CACA_DITHERING_FSTEIN) 729 { 730 error[0] = r  bg_r * ch / (DCHMAX1); 731 error[1] = g  bg_g * ch / (DCHMAX1); 732 error[2] = b  bg_b * ch / (DCHMAX1); 733 } 730 734 } 731 735 732 736 if(_caca_dithering == CACA_DITHERING_FSTEIN) 733 737 { 734 remain_r = r  (fg_r * ch + bg_r * ((2*DCHMAX1)  ch)) / (2*DCHMAX1); 735 remain_g = g  (fg_g * ch + bg_g * ((2*DCHMAX1)  ch)) / (2*DCHMAX1); 736 remain_b = b  (fg_b * ch + bg_b * ((2*DCHMAX1)  ch)) / (2*DCHMAX1); 737 remain_r_next = fs_r[x+1]; 738 remain_g_next = fs_g[x+1]; 739 remain_b_next = fs_b[x+1]; 740 fs_r[x1] += 3 * remain_r / 16; 741 fs_g[x1] += 3 * remain_g / 16; 742 fs_b[x1] += 3 * remain_b / 16; 743 fs_r[x] = 5 * remain_r / 16; 744 fs_g[x] = 5 * remain_g / 16; 745 fs_b[x] = 5 * remain_b / 16; 746 fs_r[x+1] = 1 * remain_r / 16; 747 fs_g[x+1] = 1 * remain_g / 16; 748 fs_b[x+1] = 1 * remain_b / 16; 749 remain_r = 7 * remain_r / 16; 750 remain_g = 7 * remain_g / 16; 751 remain_b = 7 * remain_b / 16; 738 remain_r = fs_r[x+1] + 7 * error[0] / 16; 739 remain_g = fs_g[x+1] + 7 * error[1] / 16; 740 remain_b = fs_b[x+1] + 7 * error[2] / 16; 741 fs_r[x1] += 3 * error[0] / 16; 742 fs_g[x1] += 3 * error[1] / 16; 743 fs_b[x1] += 3 * error[2] / 16; 744 fs_r[x] = 5 * error[0] / 16; 745 fs_g[x] = 5 * error[1] / 16; 746 fs_b[x] = 5 * error[2] / 16; 747 fs_r[x+1] = 1 * error[0] / 16; 748 fs_g[x+1] = 1 * error[1] / 16; 749 fs_b[x+1] = 1 * error[2] / 16; 752 750 } 753 751
Note: See TracChangeset
for help on using the changeset viewer.