Changeset 3935 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- May 13, 2005, 2:16:46 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r3887 r3935 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-05-1 2 00:54:49$12 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-05-14 00:16:46 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1079 1079 } 1080 1080 1081 // find the input image domain in the output image 1081 int row0 = region.y0; 1082 int row1 = region.y1; 1083 int col0 = region.x0; 1084 int col1 = region.x1; 1085 if (col1 < 1) { 1086 col1 += input->numCols; 1087 } 1088 1089 if (row1 < 1) { 1090 row1 += input->numRows; 1091 } 1092 1093 int numRows = row1 - row0; 1094 int numCols = col1 - col0; 1095 1096 if (numRows < 1 || numCols < 1) { 1097 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 1098 "The specified region is invalid."); 1099 psFree(output); 1100 return NULL; 1101 } 1102 1103 // create the output image. 1104 output = psImageRecycle(output, numCols, numRows, input->type.type); 1105 *(psS32*)&output->col0 = region.x0; 1106 *(psS32*)&output->row0 = region.y0; 1107 1082 1108 1083 1109 // loop through the output image using the domain above and transform 1084 1110 // each output pixel to input coordinates and use psImagePixelInterpolate 1085 1111 // to determine the pixel value. 1086 1087 1088 return NULL; 1112 psPlane outPosition; 1113 psPlane* inPosition = NULL; 1114 for (int row = 0; row < numRows; row++) { 1115 outPosition.y = row+row0; 1116 psF32* outputData=output->data.F32[row]; 1117 for (int col = 0; col < numCols; col++) { 1118 outPosition.x = col+col0; 1119 // apply the transform to get the position in the input image 1120 inPosition = psPlaneTransformApply(inPosition, outToIn, inPosition); 1121 1122 if (inPosition == NULL) { 1123 psError(PS_ERR_UNKNOWN, false, 1124 "Failed to apply the transform"); 1125 psFree(output); 1126 return NULL; 1127 } 1128 // interpolate the cooresponding input pixel to get the output pixel value. 1129 outputData[col] = (psF32)psImagePixelInterpolate(input, 1130 inPosition->x, inPosition->y, 1131 inputMask, inputMaskVal, exposedValue, 1132 mode); 1133 1134 } 1135 } 1136 1137 return output; 1089 1138 } 1090 1139
Note:
See TracChangeset
for help on using the changeset viewer.
