00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 static void
00021 FUNCTION_NAME(PNMImage &dest, const PNMImage &source,
00022 double width, FilterFunction *make_filter) {
00023 if (!dest.is_valid() || !source.is_valid()) {
00024 return;
00025 }
00026
00027
00028
00029
00030
00031 typedef StoreType *StoreTypeP;
00032 StoreType **matrix = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() * sizeof(StoreType *));
00033
00034 int a, b;
00035
00036 for (a=0; a<dest.ASIZE(); a++) {
00037 matrix[a] = (StoreType *)PANDA_MALLOC_ARRAY(source.BSIZE() * sizeof(StoreType));
00038 }
00039
00040
00041 double scale = (double)dest.ASIZE() / (double)source.ASIZE();
00042
00043 StoreType *temp_source = (StoreType *)PANDA_MALLOC_ARRAY(source.ASIZE() * sizeof(StoreType));
00044 StoreType *temp_dest = (StoreType *)PANDA_MALLOC_ARRAY(dest.ASIZE() * sizeof(StoreType));
00045
00046 WorkType *filter;
00047 double filter_width;
00048
00049 make_filter(scale, width, filter, filter_width);
00050
00051 for (b=0; b<source.BSIZE(); b++) {
00052 for (a=0; a<source.ASIZE(); a++) {
00053 temp_source[a] = (StoreType)(source_max * source.GETVAL(a, b));
00054 }
00055
00056 filter_row(temp_dest, dest.ASIZE(),
00057 temp_source, source.ASIZE(),
00058 scale,
00059 filter, filter_width);
00060
00061 for (a=0; a<dest.ASIZE(); a++) {
00062 matrix[a][b] = temp_dest[a];
00063 }
00064 }
00065
00066 PANDA_FREE_ARRAY(temp_source);
00067 PANDA_FREE_ARRAY(temp_dest);
00068 PANDA_FREE_ARRAY(filter);
00069
00070
00071 scale = (double)dest.BSIZE() / (double)source.BSIZE();
00072
00073 temp_dest = (StoreType *)PANDA_MALLOC_ARRAY(dest.BSIZE() * sizeof(StoreType));
00074
00075 make_filter(scale, width, filter, filter_width);
00076
00077 for (a=0; a<dest.ASIZE(); a++) {
00078
00079 filter_row(temp_dest, dest.BSIZE(),
00080 matrix[a], source.BSIZE(),
00081 scale,
00082 filter, filter_width);
00083
00084 for (b=0; b<dest.BSIZE(); b++) {
00085 dest.SETVAL(a, b, (double)temp_dest[b]/(double)source_max);
00086 }
00087 }
00088
00089 PANDA_FREE_ARRAY(temp_dest);
00090 PANDA_FREE_ARRAY(filter);
00091
00092
00093
00094 for (a=0; a<dest.ASIZE(); a++) {
00095 PANDA_FREE_ARRAY(matrix[a]);
00096 }
00097 PANDA_FREE_ARRAY(matrix);
00098 }
00099