21 FUNCTION_NAME(IMAGETYPE &dest,
const IMAGETYPE &source,
22 float width, FilterFunction *make_filter,
int channel) {
23 if (!dest.is_valid() || !source.is_valid()) {
31 typedef StoreType *StoreTypeP;
32 StoreType **matrix = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() *
sizeof(StoreType *));
36 for (a=0; a<dest.ASIZE(); a++) {
37 matrix[a] = (StoreType *)PANDA_MALLOC_ARRAY(source.BSIZE() *
sizeof(StoreType));
42 StoreType *temp_source, *temp_dest;
44 scale = (float)dest.ASIZE() / (float)source.ASIZE();
45 temp_source = (StoreType *)PANDA_MALLOC_ARRAY(source.ASIZE() *
sizeof(StoreType));
46 temp_dest = (StoreType *)PANDA_MALLOC_ARRAY(dest.ASIZE() *
sizeof(StoreType));
51 make_filter(scale, width, filter, filter_width);
53 for (b = 0; b < source.BSIZE(); b++) {
54 for (a = 0; a < source.ASIZE(); a++) {
55 temp_source[a] = (StoreType)(source_max * source.GETVAL(a, b, channel));
58 filter_row(temp_dest, dest.ASIZE(),
59 temp_source, source.ASIZE(),
61 filter, filter_width);
63 for (a = 0; a < dest.ASIZE(); a++) {
64 matrix[a][b] = temp_dest[a];
68 PANDA_FREE_ARRAY(temp_source);
69 PANDA_FREE_ARRAY(temp_dest);
70 PANDA_FREE_ARRAY(filter);
73 scale = (float)dest.BSIZE() / (float)source.BSIZE();
74 temp_dest = (StoreType *)PANDA_MALLOC_ARRAY(dest.BSIZE() *
sizeof(StoreType));
76 make_filter(scale, width, filter, filter_width);
78 for (a = 0; a < dest.ASIZE(); a++) {
79 filter_row(temp_dest, dest.BSIZE(),
80 matrix[a], source.BSIZE(),
82 filter, filter_width);
84 for (b = 0; b < dest.BSIZE(); b++) {
85 dest.SETVAL(a, b, channel, (
float)temp_dest[b]/(
float)source_max);
89 PANDA_FREE_ARRAY(temp_dest);
90 PANDA_FREE_ARRAY(filter);
94 for (a = 0; a < dest.ASIZE(); a++) {
95 PANDA_FREE_ARRAY(matrix[a]);
97 PANDA_FREE_ARRAY(matrix);