Changeset 1880
- Timestamp:
- Nov 4, 2007, 12:59:57 PM (15 years ago)
- Location:
- libcaca/trunk/cucul
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/cucul.h
r1879 r1880 222 222 int cucul_set_dither_charset(cucul_dither_t *, char const *); 223 223 char const * const * cucul_get_dither_charset_list(cucul_dither_t const *); 224 char const * cucul_get_dither_charset(cucul_dither_t const *); 224 225 int cucul_set_dither_mode(cucul_dither_t *, char const *); 225 226 char const * const * cucul_get_dither_mode_list(cucul_dither_t const *); 227 char const * cucul_get_dither_mode(cucul_dither_t const *); 226 228 int cucul_dither_bitmap(cucul_canvas_t *, int, int, int, int, 227 229 cucul_dither_t const *, void *); -
libcaca/trunk/cucul/dither.c
r1877 r1880 131 131 int gammatab[4097]; 132 132 133 /* Bitmap features */ 134 struct 135 { 136 char const *name; 137 int value; 138 } 139 antialias, color; 140 int invert; 141 142 /* Glyphs used for rendering */ 143 uint32_t const * glyphs; 144 unsigned glyph_count; 145 146 /* Current dithering method */ 133 /* Dithering features */ 134 char const *antialias_name; 135 int antialias; 136 137 char const *color_name; 138 enum color_mode color; 139 140 char const *dither_name; 147 141 void (*init_dither) (int); 148 142 unsigned int (*get_dither) (void); 149 143 void (*increment_dither) (void); 144 145 char const *glyph_name; 146 uint32_t const * glyphs; 147 unsigned glyph_count; 148 149 int invert; 150 150 }; 151 151 … … 340 340 341 341 /* Default features */ 342 d->antialias .name = "prefilter";343 d->antialias .value= 1;344 d->color.name = "full16"; 345 d->color .value = COLOR_MODE_FULL16;346 d-> invert = 0;347 348 /* Default character set */342 d->antialias_name = "prefilter"; 343 d->antialias = 1; 344 345 d->color_name = "full16"; 346 d->color = COLOR_MODE_FULL16; 347 348 d->glyph_name = "ascii"; 349 349 d->glyphs = ascii_glyphs; 350 350 d->glyph_count = sizeof(ascii_glyphs) / sizeof(*ascii_glyphs); 351 351 352 /* Default dithering mode */352 d->dither_name = "fstein"; 353 353 d->init_dither = init_fstein_dither; 354 354 d->get_dither = get_fstein_dither; 355 355 d->increment_dither = increment_fstein_dither; 356 357 d->invert = 0; 356 358 357 359 return d; … … 550 552 if(!strcasecmp(str, "none")) 551 553 { 552 d->antialias .name = "none";553 d->antialias .value= 0;554 d->antialias_name = "none"; 555 d->antialias = 0; 554 556 } 555 557 else if(!strcasecmp(str, "prefilter") || !strcasecmp(str, "default")) 556 558 { 557 d->antialias .name = "prefilter";558 d->antialias .value= 1;559 d->antialias_name = "prefilter"; 560 d->antialias = 1; 559 561 } 560 562 else … … 604 606 char const * cucul_get_dither_antialias(cucul_dither_t const *d) 605 607 { 606 return d->antialias .name;608 return d->antialias_name; 607 609 } 608 610 … … 634 636 if(!strcasecmp(str, "mono")) 635 637 { 636 d->color .name = "mono";637 d->color .value= COLOR_MODE_MONO;638 d->color_name = "mono"; 639 d->color = COLOR_MODE_MONO; 638 640 } 639 641 else if(!strcasecmp(str, "gray")) 640 642 { 641 d->color .name = "gray";642 d->color .value= COLOR_MODE_GRAY;643 d->color_name = "gray"; 644 d->color = COLOR_MODE_GRAY; 643 645 } 644 646 else if(!strcasecmp(str, "8")) 645 647 { 646 d->color .name = "8";647 d->color .value= COLOR_MODE_8;648 d->color_name = "8"; 649 d->color = COLOR_MODE_8; 648 650 } 649 651 else if(!strcasecmp(str, "16")) 650 652 { 651 d->color .name = "16";652 d->color .value= COLOR_MODE_16;653 d->color_name = "16"; 654 d->color = COLOR_MODE_16; 653 655 } 654 656 else if(!strcasecmp(str, "fullgray")) 655 657 { 656 d->color .name = "fullgray";657 d->color .value= COLOR_MODE_FULLGRAY;658 d->color_name = "fullgray"; 659 d->color = COLOR_MODE_FULLGRAY; 658 660 } 659 661 else if(!strcasecmp(str, "full8")) 660 662 { 661 d->color .name = "full8";662 d->color .value= COLOR_MODE_FULL8;663 d->color_name = "full8"; 664 d->color = COLOR_MODE_FULL8; 663 665 } 664 666 else if(!strcasecmp(str, "full16") || !strcasecmp(str, "default")) 665 667 { 666 d->color .name = "full16";667 d->color .value= COLOR_MODE_FULL16;668 d->color_name = "full16"; 669 d->color = COLOR_MODE_FULL16; 668 670 } 669 671 else … … 718 720 char const * cucul_get_dither_color(cucul_dither_t const *d) 719 721 { 720 return d->color .name;722 return d->color_name; 721 723 } 722 724 … … 745 747 if(!strcasecmp(str, "shades")) 746 748 { 749 d->glyph_name = "shades"; 747 750 d->glyphs = shades_glyphs; 748 751 d->glyph_count = sizeof(shades_glyphs) / sizeof(*shades_glyphs); … … 750 753 else if(!strcasecmp(str, "blocks")) 751 754 { 755 d->glyph_name = "blocks"; 752 756 d->glyphs = blocks_glyphs; 753 757 d->glyph_count = sizeof(blocks_glyphs) / sizeof(*blocks_glyphs); … … 755 759 else if(!strcasecmp(str, "ascii") || !strcasecmp(str, "default")) 756 760 { 761 d->glyph_name = "ascii"; 757 762 d->glyphs = ascii_glyphs; 758 763 d->glyph_count = sizeof(ascii_glyphs) / sizeof(*ascii_glyphs); … … 791 796 792 797 return list; 798 } 799 800 /** \brief Get current character set 801 * 802 * Return the given dither's current character set. 803 * 804 * This function never fails. 805 * 806 * \param d Dither object. 807 * \return A static string. 808 */ 809 char const * cucul_get_dither_charset(cucul_dither_t const *d) 810 { 811 return d->glyph_name; 793 812 } 794 813 … … 817 836 if(!strcasecmp(str, "none")) 818 837 { 838 d->dither_name = "none"; 819 839 d->init_dither = init_no_dither; 820 840 d->get_dither = get_no_dither; … … 823 843 else if(!strcasecmp(str, "ordered2")) 824 844 { 845 d->dither_name = "ordered2"; 825 846 d->init_dither = init_ordered2_dither; 826 847 d->get_dither = get_ordered2_dither; … … 829 850 else if(!strcasecmp(str, "ordered4")) 830 851 { 852 d->dither_name = "ordered4"; 831 853 d->init_dither = init_ordered4_dither; 832 854 d->get_dither = get_ordered4_dither; … … 835 857 else if(!strcasecmp(str, "ordered8")) 836 858 { 859 d->dither_name = "ordered8"; 837 860 d->init_dither = init_ordered8_dither; 838 861 d->get_dither = get_ordered8_dither; … … 841 864 else if(!strcasecmp(str, "random")) 842 865 { 866 d->dither_name = "random"; 843 867 d->init_dither = init_random_dither; 844 868 d->get_dither = get_random_dither; … … 847 871 else if(!strcasecmp(str, "fstein") || !strcasecmp(str, "default")) 848 872 { 873 d->dither_name = "fstein"; 849 874 d->init_dither = init_fstein_dither; 850 875 d->get_dither = get_fstein_dither; … … 889 914 } 890 915 916 /** \brief Get current dithering method 917 * 918 * Return the given dither's current dithering method. 919 * 920 * This function never fails. 921 * 922 * \param d Dither object. 923 * \return A static string. 924 */ 925 char const * cucul_get_dither_mode(cucul_dither_t const *d) 926 { 927 return d->dither_name; 928 } 929 891 930 /** \brief Dither a bitmap on the canvas. 892 931 * … … 959 998 960 999 /* First get RGB */ 961 if(d->antialias .value)1000 if(d->antialias) 962 1001 { 963 1002 fromx = (x - x1) * w / deltax; … … 1042 1081 1043 1082 /* FIXME: we currently only honour "full16" */ 1044 if(d->color .value== COLOR_MODE_FULL16)1083 if(d->color == COLOR_MODE_FULL16) 1045 1084 { 1046 1085 distmin = INT_MAX;
Note: See TracChangeset
for help on using the changeset viewer.