00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef GUTENPRINT_INTERNAL_DITHER_INLINED_FUNCTIONS_H
00030 #define GUTENPRINT_INTERNAL_DITHER_INLINED_FUNCTIONS_H
00031
00032
00033
00034
00035
00036
00037 static inline unsigned
00038 ditherpoint(const stpi_dither_t *d, stp_dither_matrix_impl_t *mat, int x)
00039 {
00040 if (mat->fast_mask)
00041 return mat->matrix[(mat->last_y_mod +
00042 ((x + mat->x_offset) & mat->fast_mask))];
00043
00044
00045
00046
00047
00048 if (x == mat->last_x + 1)
00049 {
00050 mat->last_x_mod++;
00051 mat->index++;
00052 if (mat->last_x_mod >= mat->x_size)
00053 {
00054 mat->last_x_mod -= mat->x_size;
00055 mat->index -= mat->x_size;
00056 }
00057 }
00058 else if (x == mat->last_x - 1)
00059 {
00060 mat->last_x_mod--;
00061 mat->index--;
00062 if (mat->last_x_mod < 0)
00063 {
00064 mat->last_x_mod += mat->x_size;
00065 mat->index += mat->x_size;
00066 }
00067 }
00068 else if (x != mat->last_x)
00069 {
00070 mat->last_x_mod = (x + mat->x_offset) % mat->x_size;
00071 mat->index = mat->last_x_mod + mat->last_y_mod;
00072 }
00073 mat->last_x = x;
00074 return mat->matrix[mat->index];
00075 }
00076
00077 static inline void
00078 set_row_ends(stpi_dither_channel_t *dc, int x)
00079 {
00080 if (dc->row_ends[0] == -1)
00081 dc->row_ends[0] = x;
00082 dc->row_ends[1] = x;
00083 }
00084
00085 #endif