Changeset 1260 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- Jul 22, 2004, 10:02:57 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r1250 r1260 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-2 1 23:39:10$12 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-22 20:02:56 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 404 404 if (in == NULL) { 405 405 psError(__func__,"Input image is NULL."); 406 psFree(out); 406 407 return NULL; 407 408 } … … 409 410 if (scale < 1) { 410 411 psError(__func__,"The scale must be positive."); 412 psFree(out); 411 413 return NULL; 412 414 } … … 414 416 if (stats == NULL) { 415 417 psError(__func__,"The stats input can not be NULL."); 418 psFree(out); 416 419 return NULL; 417 420 } … … 419 422 if (getSpecifiedStatValue(stats,&statVal) == false) { 420 423 psError(__func__,"The stat options didn't specify a single supported statistic type."); 424 psFree(out); 421 425 return NULL; 422 426 } … … 484 488 return out; 485 489 } 490 psImage* psImageResample(psImage* out, const psImage* in, int scale, psImageInterpolateMode mode) 491 { 492 int outRows; 493 int outCols; 494 float invScale; 495 496 if (in == NULL) { 497 psError(__func__,"Input image can not be NULL."); 498 psFree(out); 499 return NULL; 500 } 501 502 // create an output image of the same size and type 503 outRows = in->numRows*scale; 504 outCols = in->numCols*scale; 505 invScale = 1.0f / (float)scale; 506 507 508 #define PSIMAGE_RESAMPLE_CASE(TYPE) \ 509 case PS_TYPE_##TYPE: { \ 510 out = psImageRecycle(out,outCols, outRows, PS_TYPE_##TYPE); \ 511 for (int row=0;row<outRows;row++) { \ 512 ps##TYPE* rowData = out->data.TYPE[row]; \ 513 float inRow = (float)row * invScale; \ 514 for (int col=0;col<outCols;col++) { \ 515 rowData[col] = psImagePixelInterpolate(in,inRow,(float)col*invScale,0,mode); \ 516 } \ 517 } \ 518 break; \ 519 } 520 521 switch(in->type.type) { 522 PSIMAGE_RESAMPLE_CASE(U8) 523 PSIMAGE_RESAMPLE_CASE(U16) 524 PSIMAGE_RESAMPLE_CASE(U32) 525 PSIMAGE_RESAMPLE_CASE(U64) 526 PSIMAGE_RESAMPLE_CASE(S8) 527 PSIMAGE_RESAMPLE_CASE(S16) 528 PSIMAGE_RESAMPLE_CASE(S32) 529 PSIMAGE_RESAMPLE_CASE(S64) 530 PSIMAGE_RESAMPLE_CASE(F32) 531 PSIMAGE_RESAMPLE_CASE(F64) 532 PSIMAGE_RESAMPLE_CASE(C32) 533 PSIMAGE_RESAMPLE_CASE(C64) 534 default: 535 psError(__func__,"Unsupported type (%d)",in->type.type); 536 psFree(out); 537 return NULL; 538 } 539 540 return out; 541 } 486 542 487 543 psImage* psImageRoll(psImage* out, const psImage* in, int dx, int dy) … … 493 549 if (in == NULL) { 494 550 psError(__func__,"Input image can not be NULL."); 551 psFree(out); 495 552 return NULL; 496 553 } … … 793 850 PSIMAGE_ROTATE_ARBITRARY_LOOP(F64,MODE); \ 794 851 break; \ 852 case PS_TYPE_C32: \ 853 PSIMAGE_ROTATE_ARBITRARY_LOOP(C32,MODE); \ 854 break; \ 855 case PS_TYPE_C64: \ 856 PSIMAGE_ROTATE_ARBITRARY_LOOP(C64,MODE); \ 857 break; \ 795 858 default: \ 796 859 psError(__func__,"Image type (%d) not supported",type); \
Note:
See TracChangeset
for help on using the changeset viewer.
