void metric_generate_coeffs_for_subimage (coeffs_union_t *coeffs, bitmap_t *bitmap, int x, int y, int width, int height, metric_t *metric) { if (metric->kind == METRIC_SUBPIXEL) { bitmap_t *sub_bitmap, *scaled_bitmap; sub_bitmap = bitmap_sub(bitmap, x, y, width, height); assert(sub_bitmap != 0); //bitmap_write(sub_bitmap, "/tmp/sub.png"); scaled_bitmap = bitmap_scale(sub_bitmap, NUM_SUBPIXEL_ROWS_COLS, NUM_SUBPIXEL_ROWS_COLS, FILTER_MITCHELL); assert(scaled_bitmap != 0); bitmap_free(sub_bitmap); //bitmap_write(scaled_bitmap, "/tmp/scaled.png"); assert(scaled_bitmap->color == COLOR_RGB_8); assert(scaled_bitmap->pixel_stride == NUM_CHANNELS); assert(scaled_bitmap->row_stride == NUM_SUBPIXEL_ROWS_COLS * NUM_CHANNELS); color_convert_rgb_pixels(coeffs->subpixel.subpixels, scaled_bitmap->data, NUM_SUBPIXELS, metric->color_space); bitmap_free(scaled_bitmap); } else assert(0); }
static PComputeStatus compute_sub(PPInput *input, PPOutput output, void *state) { PINode *a, *b; real64 c, d; if(collect_inputs(input, &a, &b, &c, &d, V_NT_BITMAP)) return bitmap_sub(a, b, c, d, output); else if(collect_inputs(input, &a, &b, &c, &d, INPUT_OBJECT_WITH_GEOMETRY)) return geometry_sub(a, b, c, d, output); else p_output_real64(output, c - d); return P_COMPUTE_DONE; }