Changeset 6750 for trunk/psLib/src/imageops/psImagePixelExtract.c
- Timestamp:
- Mar 31, 2006, 4:43:57 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImagePixelExtract.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImagePixelExtract.c
r6631 r6750 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 3-17 20:38:19$10 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-04-01 02:43:57 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 57 57 return NULL; 58 58 } 59 PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 60 PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 61 PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 62 PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 59 if (input->col0 < 0) { 60 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 61 "psImage input is invalid. col0 cannot be negative.\n"); 62 psFree(out); 63 return NULL; 64 } 65 if (input->row0 < 0) { 66 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 67 "psImage input is invalid. row0 cannot be negative.\n"); 68 psFree(out); 69 return NULL; 70 } 71 if (input->numCols < 1) { 72 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 73 "psImage input is invalid. numCols must be greater than 0.\n"); 74 psFree(out); 75 return NULL; 76 } 77 if (input->numRows < 1) { 78 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 79 "psImage input is invalid. numRows must be greater than 0.\n"); 80 psFree(out); 81 return NULL; 82 } 63 83 if (row >= (input->numRows + input->row0) ) { 64 84 psError(PS_ERR_BAD_PARAMETER_NULL, true, 65 85 "Specified row number is out of range for specified image.\n"); 86 psFree(out); 66 87 return NULL; 67 88 } else if ( row < input->row0 && row >= 0 ) { 68 89 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 69 90 "Specified row number is out of range for specified image.\n"); 91 psFree(out); 70 92 return NULL; 71 93 } else if ( row < 0 ) { … … 74 96 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 75 97 "Specified row number is out of range for specified image.\n"); 98 psFree(out); 76 99 return NULL; 77 100 } … … 164 187 return NULL; 165 188 } 166 PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 167 PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 168 PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 169 PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 189 if (input->col0 < 0) { 190 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 191 "psImage input is invalid. col0 cannot be negative.\n"); 192 psFree(out); 193 return NULL; 194 } 195 if (input->row0 < 0) { 196 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 197 "psImage input is invalid. row0 cannot be negative.\n"); 198 psFree(out); 199 return NULL; 200 } 201 if (input->numCols < 1) { 202 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 203 "psImage input is invalid. numCols must be greater than 0.\n"); 204 psFree(out); 205 return NULL; 206 } 207 if (input->numRows < 1) { 208 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 209 "psImage input is invalid. numRows must be greater than 0.\n"); 210 psFree(out); 211 return NULL; 212 } 170 213 if (column >= (input->numCols + input->col0) ) { 171 214 psError(PS_ERR_BAD_PARAMETER_NULL, true, 172 215 "Specified column number is out of range for specified image.\n"); 216 psFree(out); 173 217 return NULL; 174 218 } else if ( column < input->col0 && column >= 0 ) { 175 219 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 176 220 "Specified column number is out of range for specified image.\n"); 221 psFree(out); 177 222 return NULL; 178 223 } else if ( column < 0 ) { … … 181 226 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 182 227 "Specified column number is out of range for specified image.\n"); 228 psFree(out); 183 229 return NULL; 184 230 } … … 263 309 return NULL; 264 310 } 265 PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 266 PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 267 PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 268 PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 311 if (input->col0 < 0) { 312 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 313 "psImage input is invalid. col0 cannot be negative.\n"); 314 psFree(out); 315 return NULL; 316 } 317 if (input->row0 < 0) { 318 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 319 "psImage input is invalid. row0 cannot be negative.\n"); 320 psFree(out); 321 return NULL; 322 } 323 if (input->numCols < 1) { 324 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 325 "psImage input is invalid. numCols must be greater than 0.\n"); 326 psFree(out); 327 return NULL; 328 } 329 if (input->numRows < 1) { 330 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 331 "psImage input is invalid. numRows must be greater than 0.\n"); 332 psFree(out); 333 return NULL; 334 } 269 335 /* 270 336 if (col1 < 1) { 271 337 col1 += input->numCols; 272 338 } 273 339 274 340 if (row1 < 1) { 275 341 row1 += input->numRows; 276 342 } 277 343 278 344 if ( col0 < 0 || 279 345 row0 < 0 || … … 296 362 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 297 363 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n", 298 region.x0, input->col0, input->col0+input->numCols );364 region.x0, input->col0, input->col0+input->numCols-1); 299 365 return NULL; 300 366 } … … 305 371 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 306 372 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n", 307 region.y0, input->row0, input->row0+input->numRows );373 region.y0, input->row0, input->row0+input->numRows-1); 308 374 return NULL; 309 375 } … … 315 381 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 316 382 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 317 region.x1, col1+input->col0, input->col0, input->col0+input->numCols );383 region.x1, col1+input->col0, input->col0, input->col0+input->numCols-1); 318 384 return NULL; 319 385 } … … 323 389 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 324 390 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 325 region.x1, col1, input->col0, input->col0+input->numCols );391 region.x1, col1, input->col0, input->col0+input->numCols-1); 326 392 return NULL; 327 393 } … … 332 398 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 333 399 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 334 region.y1, row1+input->row0, input->row0, input->row0+input->numRows );400 region.y1, row1+input->row0, input->row0, input->row0+input->numRows-1); 335 401 return NULL; 336 402 } … … 340 406 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 341 407 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 342 region.y1, row1, input->row0, input->row0+input->numRows );408 region.y1, row1, input->row0, input->row0+input->numRows-1); 343 409 return NULL; 344 410 } … … 583 649 return NULL; 584 650 } 585 // PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 586 // PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 587 // PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 588 // PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 651 if (input->col0 < 0) { 652 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 653 "psImage input is invalid. col0 cannot be negative.\n"); 654 psFree(out); 655 return NULL; 656 } 657 if (input->row0 < 0) { 658 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 659 "psImage input is invalid. row0 cannot be negative.\n"); 660 psFree(out); 661 return NULL; 662 } 663 if (input->numCols < 1) { 664 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 665 "psImage input is invalid. numCols must be greater than 0.\n"); 666 psFree(out); 667 return NULL; 668 } 669 if (input->numRows < 1) { 670 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 671 "psImage input is invalid. numRows must be greater than 0.\n"); 672 psFree(out); 673 return NULL; 674 } 589 675 psS32 numCols = input->numCols; 590 676 psS32 numRows = input->numRows; … … 598 684 } 599 685 600 601 float startCol = region.x0; 602 float startRow = region.y0; 603 float endCol = region.x1; 604 float endRow = region.y1; 605 if (startCol < 0 || startCol >= numCols || 606 startRow < 0 || startRow >= numRows || 607 endCol < 0 || endCol >= numCols || 608 endRow < 0 || endRow >= numRows) { 609 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 610 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 611 startCol,startRow,endCol,endRow, 612 numCols-1,numRows-1); 613 psFree(out); 614 return NULL; 615 } 686 float col0 = region.x0; 687 float row0 = region.y0; 688 float col1 = region.x1; 689 float row1 = region.y1; 690 691 //Make sure x0 of region is inside image. If so, set col0 to corresponding index number. 692 if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) { 693 col0 -= input->col0; 694 } else { 695 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 696 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n", 697 region.x0, input->col0, input->col0+input->numCols); 698 psFree(out); 699 return NULL; 700 } 701 //Make sure y0 of region is inside image. If so, set row0 to corresponding index number. 702 if (row0 >= input->row0 && row0 < (input->row0 + input->numRows) ) { 703 row0 -= input->row0; 704 } else { 705 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 706 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n", 707 region.y0, input->row0, input->row0+input->numRows); 708 psFree(out); 709 return NULL; 710 } 711 /* 712 //Make sure x1 of region is valid. If negative, index from tail (if valid). 713 if (col1 < 0) { 714 col1 += input->numCols; 715 if (col1 < 0) { 716 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 717 "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n", 718 region.x1, col1+input->col0, input->col0, input->col0+input->numCols); 719 psFree(out); 720 return NULL; 721 } 722 } else if (col1 >= input->col0 && col1 < (input->col0 + input->numCols) ) { 723 col1 -= input->col0; 724 } else { 725 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 726 "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n", 727 region.x1, col1, input->col0, input->col0+input->numCols); 728 psFree(out); 729 return NULL; 730 } 731 //Make sure y1 of region is valid. If negative, index from tail (if valid). 732 if (row1 < 0) { 733 row1 += input->numRows; 734 if (row1 < 0) { 735 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 736 "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n", 737 region.y1, row1+input->row0, input->row0, input->row0+input->numRows); 738 psFree(out); 739 return NULL; 740 } 741 } else if (row1 >= input->row0 && row1 < (input->row0 + input->numRows) ) { 742 row1 -= input->row0; 743 } else { 744 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 745 "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n", 746 region.y1, row1, input->row0, input->row0+input->numRows); 747 psFree(out); 748 return NULL; 749 } 750 */ 751 /* //Now make sure that the region makes sense. 752 if (col0 > col1 || row0 > row1) { 753 if (col0 > col1) { 754 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 755 "Invalid psRegion specified. x0=%f=%f is greater than x1=%f=%f.\n", 756 region.x0, col0, region.x1, col1); 757 } else { 758 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 759 "Invalid psRegion specified. y0=%f=%f is greater than y1=%f=%f.\n", 760 region.y0, row0, region.y1, row1); 761 } 762 psFree(out); 763 return NULL; 764 } else if (col0 == col1 && row0 == row1) { 765 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 766 "Invalid psRegion specified. Region contains only 1 pixel.\n"); 767 psFree(out); 768 return NULL; 769 } 770 */ 771 if (col1 < 0 || row1 < 0 || col0 < 0 || row0 < 0 || col0 >= numCols || col1 >= numCols || 772 row0 >= numRows || row1 >= numRows) { 773 psFree(out); 774 return NULL; 775 } 776 float startCol = col0; 777 float startRow = row0; 778 float endCol = col1; 779 float endRow = row1; 780 /* 781 float startCol = region.x0; 782 float startRow = region.y0; 783 float endCol = region.x1; 784 float endRow = region.y1; 785 if (startCol < 0 || startCol >= numCols || 786 startRow < 0 || startRow >= numRows || 787 endCol < 0 || endCol >= numCols || 788 endRow < 0 || endRow >= numRows) { 789 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 790 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 791 startCol,startRow,endCol,endRow, 792 numCols-1,numRows-1); 793 psFree(out); 794 return NULL; 795 } 796 */ 616 797 617 798 if (mode < PS_INTERPOLATE_FLAT ) {
Note:
See TracChangeset
for help on using the changeset viewer.
