| 1 | /* |
| 2 | * |
| 3 | * Very fast dither algorithm |
| 4 | * |
| 5 | * Copyright 1997-2003 Michael Sweet ([email protected]) and |
| 6 | * Robert Krawitz ([email protected]) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 16 | * for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | * Revision History: |
| 22 | * |
| 23 | * See ChangeLog |
| 24 | */ |
| 25 | |
| 26 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 27 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 28 | #endif |
| 29 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 30 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 31 | #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/ |
| 32 | #include "dither-impl.h"cxx . . $ `<file>/src/main/dither-impl.h`/ |
| 33 | #include "dither-inlined-functions.h"cxx . . $ `<file>/src/main/dither-inlined-functions.h`/ |
| 34 | |
| 35 | static inlinecxx . . $ `src/main/dither-impl.h:41:9`! void |
| 36 | print_color_very_fastcxx . . $ print_color_very_fast(83a0de3b5ad54b61).(const stpi_dither_tcxx . . $ stpi_dither_t# *d, stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc, |
| 37 | int val, int x, int y, unsigned char bit, |
| 38 | unsigned bits, int length) |
| 39 | { |
| 40 | int j; |
| 41 | (void)y; |
| 42 | |
| 43 | if (bits && val >= ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(d, &(dc->dithermatcxx . . $ dither_channel#dithermat.), x)) |
| 44 | { |
| 45 | unsigned char *tptr = dc->ptrcxx . . $ dither_channel#ptr. + d->ptr_offsetcxx . . $ dither#ptr_offset.; |
| 46 | |
| 47 | /* |
| 48 | * Lay down all of the bits in the pixel. |
| 49 | */ |
| 50 | set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(dc, x); |
| 51 | for (j = 1; j <= bits; j += j, tptr += length) |
| 52 | { |
| 53 | if (j & bits) |
| 54 | tptr[0] |= bit; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | stpi_dither_very_fastcxx . . $ stpi_dither_very_fast(525e4b1c00087d37).(stp_vars_tcxx . . $ stp_vars_t# *v, |
| 61 | int row, |
| 62 | const unsigned short *raw, |
| 63 | int duplicate_line, |
| 64 | int zero_mask, |
| 65 | const unsigned char *mask) |
| 66 | { |
| 67 | stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither"); |
| 68 | int x, |
| 69 | length; |
| 70 | unsigned char *bit_patterns; |
| 71 | unsigned char bit; |
| 72 | int i; |
| 73 | int one_bit_only = 1; |
| 74 | |
| 75 | int xerror, xstep, xmod; |
| 76 | (void)duplicate_line; |
| 77 | |
| 78 | if ((zero_mask & ((1 << CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)) - 1)) == |
| 79 | ((1 << CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)) - 1)) |
| 80 | return; |
| 81 | |
| 82 | length = (d->dst_widthcxx . . $ dither#dst_width. + 7) / 8; |
| 83 | |
| 84 | bit = 128; |
| 85 | xstep = CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d) * (d->src_widthcxx . . $ dither#src_width. / d->dst_widthcxx . . $ dither#dst_width.); |
| 86 | xmod = d->src_widthcxx . . $ dither#src_width. % d->dst_widthcxx . . $ dither#dst_width.; |
| 87 | xerror = 0; |
| 88 | |
| 89 | bit_patterns = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(unsigned char) * CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)); |
| 90 | for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++) |
| 91 | { |
| 92 | stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc = &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)); |
| 93 | if (dc->nlevelscxx . . $ dither_channel#nlevels. > 0) |
| 94 | bit_patterns[i] = dc->rangescxx . . $ dither_channel#ranges.[dc->nlevelscxx . . $ dither_channel#nlevels. - 1].uppercxx . . $ dither_segment#upper.->bitscxx . . $ ink_defn#bits.; |
| 95 | if (bit_patterns[i] != 1) |
| 96 | one_bit_only = 0; |
| 97 | } |
| 98 | if (one_bit_only) |
| 99 | { |
| 100 | for (x = 0; x < d->dst_widthcxx . . $ dither#dst_width.; x ++) |
| 101 | { |
| 102 | if (!mask || (*(mask + d->ptr_offsetcxx . . $ dither#ptr_offset.) & bit)) |
| 103 | { |
| 104 | for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++) |
| 105 | { |
| 106 | if (raw[i] && |
| 107 | raw[i] >= ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).dithermatcxx . . $ dither_channel#dithermat.), x)) |
| 108 | { |
| 109 | set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(&(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), x); |
| 110 | CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).ptrcxx . . $ dither_channel#ptr.[d->ptr_offsetcxx . . $ dither#ptr_offset.] |= bit; |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, raw, CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d), |
| 115 | xerror, xstep, xmod); |
| 116 | } |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | for (x = 0; x < d->dst_widthcxx . . $ dither#dst_width.; x ++) |
| 121 | { |
| 122 | if (!mask || (*(mask + d->ptr_offsetcxx . . $ dither#ptr_offset.) & bit)) |
| 123 | { |
| 124 | for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++) |
| 125 | { |
| 126 | if (CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).ptrcxx . . $ dither_channel#ptr. && raw[i]) |
| 127 | print_color_very_fastcxx . . $ print_color_very_fast(83a0de3b5ad54b61).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), raw[i], x, row, |
| 128 | bit, bit_patterns[i], length); |
| 129 | } |
| 130 | } |
| 131 | ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, raw, CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d), |
| 132 | xerror, xstep, xmod); |
| 133 | } |
| 134 | } |
| 135 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(bit_patterns); |
| 136 | } |