IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 17, 2005, 1:44:22 PM (21 years ago)
Author:
desonia
Message:

added enhancement to psFree so that it sets the reference being freed to
NULL (thanks Gus).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/image/tst_psImageGeomManip.c

    r4214 r4308  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-06-11 02:19:05 $
     8 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-06-17 23:44:22 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    10771077static psS32 testImageTransform(void)
    10781078{
    1079 
    1080     /// XXX: TODO
     1079    int cols = 16;
     1080    int rows = 32;
     1081
     1082    psPlaneTransform* trans = psPlaneTransformAlloc(2,2);
     1083    trans->x->coeff[1][0] = 0.5;
     1084    trans->y->coeff[0][1] = 1.5;
     1085
     1086    psImage* in = psImageAlloc(cols,rows,PS_TYPE_F32);
     1087    for (psS32 row=0;row<rows;row++) {
     1088        psF32* inRow = in->data.F32[row];
     1089        for (psS32 col=0;col<cols;col++) {
     1090            inRow[col] = (psF32)row+(psF32)col/1000.0f;
     1091        }
     1092    }
     1093
     1094    psImage* out = psImageTransform(NULL,
     1095                                    NULL,
     1096                                    in,
     1097                                    NULL,
     1098                                    0,
     1099                                    trans,
     1100                                    psRegionSet(0,cols*2,0,rows*2),
     1101                                    NULL,
     1102                                    PS_INTERPOLATE_FLAT,
     1103                                    -1);
     1104
     1105    if (out == NULL) {
     1106        psError(PS_ERR_UNKNOWN, false,
     1107                "out == NULL");
     1108        return 1;
     1109    }
     1110    if (out->type.type != PS_TYPE_F32) {
     1111        psError(PS_ERR_UNKNOWN, false,
     1112                "out->type.type != PS_TYPE_F32, out->type.type == %d",
     1113                out->type.type);
     1114        return 2;
     1115    }
     1116    if (out->numRows != rows*2 || out->numCols != cols*2) {
     1117        psError(PS_ERR_UNKNOWN, false,
     1118                "out size is %dx%d, not %dx%d",
     1119                out->numCols, out->numRows, cols*2, rows);
     1120        return 3;
     1121    }
     1122
     1123    for (psS32 row=0;row<out->numRows;row++) {
     1124        psF32* outRow = out->data.F32[row];
     1125        for (psS32 col=0;col<cols;col++) {
     1126            float inValue = p_psImagePixelInterpolateFLAT_F32(in,
     1127                            col*trans->x->coeff[1][0]+trans->x->coeff[0][0],
     1128                            row*trans->y->coeff[0][1]+trans->y->coeff[0][0],
     1129                            NULL, 0,
     1130                            -1);
     1131            if (fabsf(outRow[col] - inValue) > FLT_EPSILON*10) {
     1132                psError(PS_ERR_UNKNOWN, false,
     1133                        "out at %d,%d was %g, expected %g",
     1134                        col,row,outRow[col], inValue);
     1135                return 4;
     1136            }
     1137        }
     1138    }
     1139
     1140    psFree(out);
     1141    psFree(in);
     1142    psFree(trans);
    10811143    return 0;
    10821144}
Note: See TracChangeset for help on using the changeset viewer.