Changeset 2835 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- Dec 27, 2004, 3:43:17 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r2807 r2835 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-2 3 19:14:15$12 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-28 01:42:28 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 195 195 psU32 imageColLimit; 196 196 psElemType type; 197 psU32 pixelsOverlaid = 0; 197 198 198 199 if (image == NULL || overlay == NULL) { 199 200 psError(PS_ERR_BAD_PARAMETER_NULL, true, 200 201 PS_ERRORTEXT_psImage_IMAGE_NULL); 201 return 1;202 return pixelsOverlaid; 202 203 } 203 204 … … 205 206 psError(PS_ERR_BAD_PARAMETER_NULL, true, 206 207 PS_ERRORTEXT_psImageManip_OPERATION_NULL); 207 return 1;208 return pixelsOverlaid; 208 209 } 209 210 … … 218 219 PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH, 219 220 typeStrOverlay, typeStr); 220 return 2;221 return pixelsOverlaid; 221 222 } 222 223 … … 238 239 col0, imageColLimit, row0, imageRowLimit, 239 240 imageNumCols, imageNumRows); 240 return 3; 241 } 242 243 switch (type) { 244 245 #define psImageOverlayCase(DATATYPE) \ 246 case PS_TYPE_##DATATYPE: \ 247 for (psU32 row=row0;row<imageRowLimit;row++) { \ 241 return pixelsOverlaid; 242 } 243 244 245 #define psImageOverlayLoop(DATATYPE,OP) { \ 246 for (int row=row0;row<imageRowLimit;row++) { \ 248 247 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 249 248 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \ 250 for (psU32 col=col0;col<imageColLimit;col++) { \ 251 switch (*op) { \ 252 case '+': \ 253 imageRow[col] += overlayRow[col-col0]; \ 254 break; \ 255 case '-': \ 256 imageRow[col] -= overlayRow[col-col0]; \ 257 break; \ 258 case '*': \ 259 imageRow[col] *= overlayRow[col-col0]; \ 260 break; \ 261 case '/': \ 262 imageRow[col] /= overlayRow[col-col0]; \ 263 break; \ 264 case '=': \ 265 imageRow[col] = overlayRow[col-col0]; \ 266 break; \ 267 default: \ 268 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 269 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 270 op); \ 271 return 5; \ 272 } \ 273 } \ 274 } \ 275 break; 276 249 for (int col=col0;col<imageColLimit;col++) { \ 250 imageRow[col] OP overlayRow[col-col0]; \ 251 } \ 252 } \ 253 pixelsOverlaid += (imageRowLimit - row0) * (imageColLimit - col0); \ 254 } 255 256 #define psImageOverlayCase(DATATYPE) \ 257 case PS_TYPE_##DATATYPE: \ 258 switch (*op) { \ 259 case '+': \ 260 psImageOverlayLoop(DATATYPE,+=); \ 261 break; \ 262 case '-': \ 263 psImageOverlayLoop(DATATYPE,-=); \ 264 break; \ 265 case '*': \ 266 psImageOverlayLoop(DATATYPE,*=); \ 267 break; \ 268 case '/': \ 269 psImageOverlayLoop(DATATYPE,/=); \ 270 break; \ 271 case '=': \ 272 psImageOverlayLoop(DATATYPE,=); \ 273 break; \ 274 default: \ 275 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 276 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 277 op); \ 278 return pixelsOverlaid; \ 279 } \ 280 break; 281 282 switch (type) { 277 283 psImageOverlayCase(U8); 278 284 psImageOverlayCase(U16); 279 // psImageOverlayCase(U32);Not a requirement280 // psImageOverlayCase(U64);Not a requirement285 psImageOverlayCase(U32); // Not a requirement 286 psImageOverlayCase(U64); // Not a requirement 281 287 psImageOverlayCase(S8); 282 288 psImageOverlayCase(S16); 283 // psImageOverlayCase(S32);Not a requirement284 // psImageOverlayCase(S64);Not a requirement289 psImageOverlayCase(S32); // Not a requirement 290 psImageOverlayCase(S64); // Not a requirement 285 291 psImageOverlayCase(F32); 286 292 psImageOverlayCase(F64); … … 294 300 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 295 301 typeStr); 296 return 6;297 } 298 } 299 300 return 0;302 return pixelsOverlaid; 303 } 304 } 305 306 return pixelsOverlaid; 301 307 } 302 308 … … 832 838 833 839 /* optimized public domain rotation routine by Karl Lager 834 * 835 * float cosT,sinT; 836 * cosT = cos(t); 837 * sinT = sin(t); 838 * for (y = min_y; y <= max_y; y++) { 839 * x' = min_x * cosT + y * sinT + x1'; 840 * y' = y * cosT - min_x * sinT + y1'; 841 * for (x = min_x; x <= max_x; x++) { 840 * 841 * float cosT,sinT; 842 * cosT = cos(t); 843 * sinT = sin(t); 844 * for (y = min_y; y <= max_y; y++) { 845 * x' = min_x * cosT + y * sinT + x1'; 846 * y' = y * cosT - min_x * sinT + y1'; 847 * for (x = min_x; x <= max_x; x++) { 842 848 * if (x', y') is in the bounds of the bitmap, get pixel 843 * (x', y') and plot the pixel to (x, y) on screen. 844 * x' += cosT; 845 * y' -= sinT; 849 * (x', y') and plot the pixel to (x, y) on screen. 850 * x' += cosT; 851 * y' -= sinT; 846 852 * } 847 * } 853 * } 848 854 */ 849 855
Note:
See TracChangeset
for help on using the changeset viewer.
