void process(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out) { const int ch = piece->colors; const int ch_width = ch * roi_in->width; const struct dt_interpolation *interpolation = dt_interpolation_new(DT_INTERPOLATION_USERPREF); const dt_iop_scalepixels_data_t * const d = piece->data; #ifdef _OPENMP #pragma omp parallel for schedule(static) default(none) shared(interpolation) #endif // (slow) point-by-point transformation. // TODO: optimize with scanlines and linear steps between? for(int j = 0; j < roi_out->height; j++) { float *out = ((float *)ovoid) + (size_t)4 * j * roi_out->width; for(int i = 0; i < roi_out->width; i++, out += 4) { float x = i*d->x_scale; float y = j*d->y_scale; dt_interpolation_compute_pixel4c(interpolation, (float *)ivoid, out, x, y, roi_in->width, roi_in->height, ch_width); } } }
// 3rd (final) pass: you get this input region (may be different from what was requested above), // do your best to fill the output region! void process(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out) { const int ch = piece->colors; const int ch_width = ch * roi_in->width; const float scale = roi_in->scale / piece->iscale; assert(ch == 4); const struct dt_interpolation *interpolation = dt_interpolation_new(DT_INTERPOLATION_USERPREF); #ifdef _OPENMP #pragma omp parallel for schedule(static) default(none) shared(piece, interpolation) #endif // (slow) point-by-point transformation. // TODO: optimize with scanlines and linear steps between? for(int j = 0; j < roi_out->height; j++) { float *out = ((float *)ovoid) + (size_t)ch * j * roi_out->width; for(int i = 0; i < roi_out->width; i++, out += ch) { float pi[2], po[2]; pi[0] = roi_out->x + i; pi[1] = roi_out->y + j; backtransform(piece, scale, pi, po); po[0] -= roi_in->x; po[1] -= roi_in->y; dt_interpolation_compute_pixel4c(interpolation, (float *)ivoid, out, po[0], po[1], roi_in->width, roi_in->height, ch_width); } } }