Changeset 1840 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- Sep 21, 2004, 12:30:19 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (38 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r1827 r1840 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09- 17 23:57:41$12 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-21 22:30:19 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psMemory.h" 27 27 #include "psImageExtraction.h" 28 29 #include "psImageErrors.h" 28 30 29 31 int psImageClip(psImage* input, … … 42 44 43 45 if (max < min) { 44 psError(__func__, "psImageClip can not be invoked with max < min."); 46 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", 47 PS_ERR_BAD_PARAMETER_VALUE, true, 48 PS_ERRORTEXT_psImageManip_MAXMIN, 49 (double)min,(double)max); 45 50 return 0; 46 51 } … … 51 56 switch (input->type.type) { 52 57 53 #define psImageClipCase(type ,typename) \58 #define psImageClipCase(type) \ 54 59 case PS_TYPE_##type: { \ 55 60 if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \ 56 psError(__func__, "Specified vmin (%g) is outside of image's " \ 57 typename " pixel range (%g to %g)", \ 58 vmin,(psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 61 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 62 PS_ERR_BAD_PARAMETER_VALUE, true, \ 63 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 64 "vmin",vmin, PS_TYPE_##type##_NAME, \ 65 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 59 66 } \ 60 67 if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \ 61 psError(__func__, "Specified vmax (%g) is outside of image's " \ 62 typename " pixel range (%g to %g)", \ 63 vmax,(psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 68 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 69 PS_ERR_BAD_PARAMETER_VALUE, true, \ 70 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 71 "vmax",vmax, PS_TYPE_##type##_NAME, \ 72 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 64 73 } \ 65 74 for (unsigned int row = 0;row<numRows;row++) { \ … … 78 87 break; 79 88 80 #define psImageClipCaseComplex(type, typename,absfcn)\89 #define psImageClipCaseComplex(type,absfcn)\ 81 90 case PS_TYPE_##type: { \ 82 91 if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \ 83 psError(__func__, "Specified vmin (%g) is outside of image's " \ 84 typename " pixel range", \ 85 vmin); \ 92 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 93 PS_ERR_BAD_PARAMETER_VALUE, true, \ 94 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 95 "vmin",vmin, PS_TYPE_##type##_NAME, \ 96 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 86 97 } \ 87 98 if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \ 88 psError(__func__, "Specified vmax (%g) is outside of image's " \ 89 typename " pixel range", \ 90 vmax); \ 99 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 100 PS_ERR_BAD_PARAMETER_VALUE, true, \ 101 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 102 "vmax",vmax, PS_TYPE_##type##_NAME, \ 103 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 91 104 } \ 92 105 for (unsigned int row = 0;row<numRows;row++) { \ … … 105 118 break; 106 119 107 psImageClipCase(S8, "psS8") 108 psImageClipCase(S16, "psS16") 109 psImageClipCase(S32, "psS32") 110 psImageClipCase(S64, "psS64") 111 psImageClipCase(U8, "psU8") 112 psImageClipCase(U16, "psU16") 113 psImageClipCase(U32, "psU32") 114 psImageClipCase(U64, "psU64") 115 psImageClipCase(F32, "psF32") 116 psImageClipCase(F64, "psF64") 117 psImageClipCaseComplex(C32, "psC32", cabsf) 118 psImageClipCaseComplex(C64, "psC64", cabs) 119 120 default: 121 psError(__func__, "psImageClip does not support the given datatype (%d)", input->type.type); 120 psImageClipCase(S8) 121 psImageClipCase(S16) 122 psImageClipCase(S32) 123 psImageClipCase(S64) 124 psImageClipCase(U8) 125 psImageClipCase(U16) 126 psImageClipCase(U32) 127 psImageClipCase(U64) 128 psImageClipCase(F32) 129 psImageClipCase(F64) 130 psImageClipCaseComplex(C32, cabsf) 131 psImageClipCaseComplex(C64, cabs) 132 133 default: { 134 char* typeStr; 135 PS_TYPE_NAME(typeStr,input->type.type); 136 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", 137 PS_ERR_BAD_PARAMETER_TYPE, true, 138 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 139 typeStr); 140 } 122 141 } 123 142 … … 158 177 psImageClipNaNCase(C64) 159 178 160 default: 161 psError(__func__, "psImageClip does not support the given datatype (%d)", input->type.type); 179 default: { 180 char* typeStr; 181 PS_TYPE_NAME(typeStr,input->type.type); 182 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipNaN", 183 PS_ERR_BAD_PARAMETER_TYPE, true, 184 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 185 typeStr); 186 } 162 187 } 163 188 … … 180 205 181 206 if (image == NULL || overlay == NULL) { 182 psError(__func__, "one of the input images was NULL."); 207 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 208 PS_ERR_BAD_PARAMETER_NULL, true, 209 PS_ERRORTEXT_psImage_IMAGE_NULL); 183 210 return 1; 184 211 } 185 212 186 213 if (op == NULL) { 187 psError(__func__, "Operation can not be NULL."); 214 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 215 PS_ERR_BAD_PARAMETER_NULL, true, 216 PS_ERRORTEXT_psImageManip_OPERATION_NULL); 188 217 return 1; 189 218 } … … 192 221 193 222 if (type != overlay->type.type) { 194 psError(__func__, "Image and overlay datatypes must match. (%d vs %d)", type, overlay->type.type); 223 char* typeStr; 224 char* typeStrOverlay; 225 PS_TYPE_NAME(typeStr,type); 226 PS_TYPE_NAME(typeStrOverlay,overlay->type.type); 227 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 228 PS_ERR_BAD_PARAMETER_TYPE, true, 229 PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH, 230 typeStrOverlay, typeStr); 195 231 return 2; 196 232 } … … 200 236 overlayNumRows = overlay->numRows; 201 237 overlayNumCols = overlay->numCols; 202 203 /* check row0/col0 to see if it is within the image size */204 if (row0 < 0 || col0 < 0 || row0 >= imageNumRows || col0 >= imageNumCols) {205 psError(__func__,206 "Overlay origin of (%d,%d) is outside of the image dimensions (%d x %d).",207 col0, row0, imageNumCols, imageNumRows);208 return 3;209 }210 211 /* check if overlay is totally withing input image */212 238 imageRowLimit = row0 + overlayNumRows; 213 239 imageColLimit = col0 + overlayNumCols; 214 if (imageRowLimit > imageNumRows || imageColLimit > imageNumCols) { 215 psError(__func__, 216 "Overlay image (%d,%d -> %d,%d) is partially outside" 217 " of the input image (%d x %d).", 218 col0, row0, col0 + overlayNumCols - 1, row0 + overlayNumRows - 1, imageNumCols, imageNumRows); 219 return 4; 240 241 /* check to see if overlay is within the input image */ 242 if ( row0 < 0 || 243 col0 < 0 || 244 imageRowLimit > imageNumRows || 245 imageColLimit > imageNumCols) { 246 247 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 248 PS_ERR_BAD_PARAMETER_VALUE, true, 249 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 250 col0, imageColLimit, row0, imageRowLimit, 251 imageNumCols, imageNumRows); 252 return 3; 220 253 } 221 254 … … 245 278 break; \ 246 279 default: \ 247 psError(__func__,"Unknown operation %s",op); \ 280 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", \ 281 PS_ERR_BAD_PARAMETER_VALUE, true, \ 282 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 283 op); \ 248 284 return 5; \ 249 285 } \ … … 265 301 psImageOverlayCase(C64); 266 302 267 default: 268 psError(__func__, "Can not operate on type %d.", type); 303 default: { 304 char* typeStr; 305 PS_TYPE_NAME(typeStr,type); 306 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 307 PS_ERR_BAD_PARAMETER_TYPE, true, 308 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 309 typeStr); 310 } 269 311 } 270 312 … … 287 329 288 330 if (input == NULL) { 289 psError(__func__, "Can not perform clip on NULL image"); 331 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 332 PS_ERR_BAD_PARAMETER_NULL, true, 333 PS_ERRORTEXT_psImage_IMAGE_NULL); 290 334 return 0; 291 335 } 292 336 293 337 if (realMax < realMin) { 294 psError(__func__, 295 "psImageClipComplexRegion can not be invoked with " "max < min in the real image space."); 338 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 339 PS_ERR_BAD_PARAMETER_VALUE, true, 340 PS_ERRORTEXT_psImageManip_MAXMIN_REAL, 341 (double)realMin, (double)realMax); 296 342 return 0; 297 343 } 298 344 if (imagMax < imagMin) { 299 psError(__func__, 300 "psImageClipComplexRegion can not be invoked with " 301 "max < min in the imaginary image space."); 345 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 346 PS_ERR_BAD_PARAMETER_VALUE, true, 347 PS_ERRORTEXT_psImageManip_MAXMIN_IMAG, 348 (double)imagMin, (double)imagMax); 302 349 return 0; 303 350 } … … 306 353 numCols = input->numCols; 307 354 308 #define psImageClipComplexRegionCase(type, typename,realfcn,imagfcn) \355 #define psImageClipComplexRegionCase(type,realfcn,imagfcn) \ 309 356 case PS_TYPE_##type: { \ 310 357 if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \ 311 358 realfcn(vmin) > PS_MAX_##type || imagfcn(vmin) > PS_MAX_##type ) { \ 312 psError(__func__, "Specified vmin (%g%+gi) is outside of image's " \ 313 typename " pixel range", \ 314 creal(vmin),cimag(vmin)); \ 359 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", \ 360 PS_ERR_BAD_PARAMETER_VALUE, true, \ 361 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 362 "vmin", creal(vmin), cimag(vmin), \ 363 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \ 315 364 break; \ 316 365 } \ 317 366 if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \ 318 367 realfcn(vmax) < PS_MIN_##type || imagfcn(vmax) < PS_MIN_##type ) { \ 319 psError(__func__, "Specified vmax (%g%+gi) is outside of image's " \ 320 typename " pixel range", \ 321 creal(vmax),cimag(vmax)); \ 368 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", \ 369 PS_ERR_BAD_PARAMETER_VALUE, true, \ 370 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 371 "vmax", creal(vmax), cimag(vmax), \ 372 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \ 322 373 break; \ 323 374 } \ … … 339 390 switch (input->type.type) { 340 391 341 psImageClipComplexRegionCase(C32, "psC32", crealf, cimagf) 342 psImageClipComplexRegionCase(C64, "psC64", creal, cimag) 343 344 default: 345 psError(__func__, "psImageClip does not support the given datatype (%d)", input->type.type); 392 psImageClipComplexRegionCase(C32, crealf, cimagf) 393 psImageClipComplexRegionCase(C64, creal, cimag) 394 395 default: { 396 char* typeStr; 397 PS_TYPE_NAME(typeStr,input->type.type); 398 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 399 PS_ERR_BAD_PARAMETER_TYPE, true, 400 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 401 typeStr); 402 } 346 403 } 347 404 … … 367 424 368 425 if (in == NULL) { 369 psError(__func__, "Input image is NULL."); 426 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 427 PS_ERR_BAD_PARAMETER_NULL, true, 428 PS_ERRORTEXT_psImage_IMAGE_NULL); 370 429 psFree(out); 371 430 return NULL; … … 373 432 374 433 if (scale < 1) { 375 psError(__func__, "The scale must be positive."); 434 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 435 PS_ERR_BAD_PARAMETER_VALUE, true, 436 PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE, 437 scale); 376 438 psFree(out); 377 439 return NULL; … … 379 441 380 442 if (stats == NULL) { 381 psError(__func__, "The stats input can not be NULL."); 443 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 444 PS_ERR_BAD_PARAMETER_NULL, true, 445 PS_ERRORTEXT_psImage_STAT_NULL); 382 446 psFree(out); 383 447 return NULL; … … 385 449 386 450 if (p_psGetStatValue(stats, &statVal) == false) { 387 psError(__func__, "The stat options didn't specify a single supported statistic type."); 451 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 452 PS_ERR_BAD_PARAMETER_VALUE, true, 453 PS_ERRORTEXT_psImage_BAD_STAT, 454 stats->options); 388 455 psFree(out); 389 456 return NULL; … … 394 461 if (mask != NULL) { 395 462 if (mask->type.type != PS_TYPE_MASK) { 396 psError(__func__, "The mask datatype must be %s (%d).", 397 PS_TYPE_MASK_NAME, 398 mask->type.type); 463 char* typeStr; 464 PS_TYPE_NAME(typeStr,mask->type.type); 465 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 466 PS_ERR_BAD_PARAMETER_TYPE, true, 467 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 468 typeStr, PS_TYPE_MASK_NAME); 399 469 psFree(out); 400 470 psFree(vec); … … 462 532 PS_IMAGE_REBIN_CASE(C32); 463 533 PS_IMAGE_REBIN_CASE(C64); 464 default: 465 psError(__func__, "Input image type not supported."); 466 psFree(out); 467 out = NULL; 534 535 default: { 536 char* typeStr; 537 PS_TYPE_NAME(typeStr,in->type.type); 538 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 539 PS_ERR_BAD_PARAMETER_TYPE, true, 540 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 541 typeStr); 542 psFree(out); 543 out = NULL; 544 } 468 545 } 469 546 … … 484 561 485 562 if (in == NULL) { 486 psError(__func__, "Input image can not be NULL."); 563 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 564 PS_ERR_BAD_PARAMETER_NULL, true, 565 PS_ERRORTEXT_psImage_IMAGE_NULL); 487 566 psFree(out); 488 567 return NULL; … … 520 599 PSIMAGE_RESAMPLE_CASE(C32) 521 600 PSIMAGE_RESAMPLE_CASE(C64) 522 default: 523 psError(__func__, "Unsupported type (%d)", in->type.type); 524 psFree(out); 525 return NULL; 601 default: { 602 char* typeStr; 603 PS_TYPE_NAME(typeStr,in->type.type); 604 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 605 PS_ERR_BAD_PARAMETER_TYPE, true, 606 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 607 typeStr); 608 psFree(out); 609 out = NULL; 610 } 526 611 } 527 612 … … 539 624 540 625 if (in == NULL) { 541 psError(__func__, "Input image can not be NULL."); 626 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRoll", 627 PS_ERR_BAD_PARAMETER_NULL, true, 628 PS_ERRORTEXT_psImage_IMAGE_NULL); 542 629 psFree(out); 543 630 return NULL; … … 570 657 inRowNumber -= outRows; 571 658 } 572 psU8* inRow = in->data.U8[inRowNumber]; // to 573 574 // allow 575 576 // byte 577 // arithmetic, 578 579 // but for all types 659 psU8* inRow = in->data.U8[inRowNumber]; // use byte arithmetic for all types 580 660 psU8* outRow = out->data.U8[row]; 581 661 … … 594 674 { 595 675 if (in == NULL) { 596 psError(__func__, "The input image was NULL."); 676 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 677 PS_ERR_BAD_PARAMETER_NULL, true, 678 PS_ERRORTEXT_psImage_IMAGE_NULL); 597 679 psFree(out); 598 680 return NULL; … … 635 717 PSIMAGE_ROTATE_LEFT_90(C32); 636 718 PSIMAGE_ROTATE_LEFT_90(C64); 637 default: 638 psError(__func__, "Unsupported type (%d)", type); 639 psFree(out); 640 return NULL; 719 default: { 720 char* typeStr; 721 PS_TYPE_NAME(typeStr,type); 722 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 723 PS_ERR_BAD_PARAMETER_TYPE, true, 724 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 725 typeStr); 726 psFree(out); 727 return NULL; 728 } 641 729 } 642 730 } else if (fabsf(angle - 180.0f) < FLT_EPSILON) { … … 675 763 PSIMAGE_ROTATE_180_CASE(C32); 676 764 PSIMAGE_ROTATE_180_CASE(C64); 677 default: 678 psError(__func__, "Unsupported type (%d)", type); 679 psFree(out); 680 return NULL; 765 766 default: { 767 char* typeStr; 768 PS_TYPE_NAME(typeStr,type); 769 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 770 PS_ERR_BAD_PARAMETER_TYPE, true, 771 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 772 typeStr); 773 psFree(out); 774 return NULL; 775 } 681 776 } 682 777 } else if (fabsf(angle - 270.0f) < FLT_EPSILON) { … … 714 809 PSIMAGE_ROTATE_RIGHT_90(C32); 715 810 PSIMAGE_ROTATE_RIGHT_90(C64); 716 default: 717 psError(__func__, "Unsupported type (%d)", type); 718 psFree(out); 719 return NULL; 811 812 default: { 813 char* typeStr; 814 PS_TYPE_NAME(typeStr,type); 815 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 816 PS_ERR_BAD_PARAMETER_TYPE, true, 817 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 818 typeStr); 819 psFree(out); 820 return NULL; 821 } 720 822 } 721 823 } else if (fabsf(angle) < FLT_EPSILON) { … … 731 833 double sinT = sinf(t); 732 834 733 // calculate the corners of the rotated 734 // image so we know the proper 735 // output image size. 736 // x' = x cos(t) + y sin(t); i.e, x' = 737 // (x-centerX)*cosT + 738 // (y-centerY)*sinT; 739 // y' = y cos(t) - x sin(t); i.e. y' = 740 // (y-centerY)*cosT - 741 // (x-centerX)*sinT; 835 // calculate the corners of the rotated image so we know the proper output image size. 836 // x' = x cos(t) + y sin(t); i.e, x' = (x-centerX)*cosT + (y-centerY)*sinT; 837 // y' = y cos(t) - x sin(t); i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT; 742 838 743 839 int outCols = ceil(abs(numCols * cosT) + abs(numRows * sinT)) + 1; … … 748 844 out = psImageRecycle(out, outCols, outRows, type); 749 845 750 /* optimized public domain rotation routine by Karl Lager float cosT,sinT; cosT = cos(t); sinT = 751 * sin(t); for (y = min_y; y <= max_y; y++) { x' = min_x * cosT + y * sinT + x1'; y' = y * cosT - 752 * min_x * sinT + y1'; for (x = min_x; x <= max_x; x++) { if (x', y') * * * * * * * * is in the 753 * bounds of the bitmap, get pixel(x', y') and plot the pixel to (x, y) on screen. x' += cosT; y' -= 754 * sinT; } } */ 755 756 // precalculate some figures that are 757 // used within loop 846 /* optimized public domain rotation routine by Karl Lager 847 * 848 * float cosT,sinT; 849 * cosT = cos(t); 850 * sinT = sin(t); 851 * for (y = min_y; y <= max_y; y++) { 852 * x' = min_x * cosT + y * sinT + x1'; 853 * y' = y * cosT - min_x * sinT + y1'; 854 * for (x = min_x; x <= max_x; x++) { 855 * if (x', y') is in the bounds of the bitmap, get pixel 856 * (x', y') and plot the pixel to (x, y) on screen. 857 * x' += cosT; 858 * y' -= sinT; 859 * } 860 * } 861 */ 862 863 // precalculate some figures that are used within loop 758 864 float minXTimesCosTPlusCenterX = minX * cosT + centerX; 759 865 float CenterYMinusminXTimesSinT = centerY - minX * sinT; 760 866 761 867 #define PSIMAGE_ROTATE_ARBITRARY_LOOP(TYPE,MODE) { \ 762 if (creal(unexposedValue) < PS_MIN_##TYPE || creal(unexposedValue) > PS_MAX_##TYPE || \ 763 cimag(unexposedValue) < PS_MIN_##TYPE || cimag(unexposedValue) > PS_MAX_##TYPE) { \ 764 psError(__func__,"The given unexposedValue (%g%+g) is outside of the " \ 765 "image type's range (%g->%g).", \ 766 creal(unexposedValue),cimag(unexposedValue), \ 767 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 868 if (creal(unexposedValue) < PS_MIN_##TYPE || \ 869 creal(unexposedValue) > PS_MAX_##TYPE || \ 870 cimag(unexposedValue) < PS_MIN_##TYPE || \ 871 cimag(unexposedValue) > PS_MAX_##TYPE) { \ 872 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \ 873 PS_ERR_BAD_PARAMETER_VALUE, true, \ 874 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 875 "unexposedValue", \ 876 creal(unexposedValue),cimag(unexposedValue), \ 877 PS_TYPE_##TYPE##_NAME, \ 878 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 768 879 psFree(out); \ 769 880 out = NULL; \ … … 824 935 PSIMAGE_ROTATE_ARBITRARY_LOOP(C64,MODE); \ 825 936 break; \ 826 default: \ 827 psError(__func__,"Image type (%d) not supported",type); \ 828 psFree(out); \ 829 out = NULL; \ 937 default: { \ 938 char* typeStr; \ 939 PS_TYPE_NAME(typeStr,type); \ 940 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \ 941 PS_ERR_BAD_PARAMETER_TYPE, true, \ 942 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \ 943 typeStr); \ 944 psFree(out); \ 945 out = NULL; \ 946 } \ 830 947 } \ 831 948 break; … … 835 952 PSIMAGE_ROTATE_ARBITRARY_CASE(BILINEAR); 836 953 default: 837 psError(__func__, "Unsupported interpolation mode (%d)", mode); 954 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 955 PS_ERR_BAD_PARAMETER_VALUE, true, 956 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 957 mode); 838 958 psFree(out); 839 959 out = NULL; … … 857 977 858 978 if (in == NULL) { 859 psError(__func__, "Input image can not be NULL."); 979 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", 980 PS_ERR_BAD_PARAMETER_NULL, true, 981 PS_ERRORTEXT_psImage_IMAGE_NULL); 860 982 psFree(out); 861 983 return NULL; … … 871 993 #define PSIMAGE_SHIFT_CASE(MODE,TYPE) \ 872 994 case PS_TYPE_##TYPE: \ 873 if (creal(unexposedValue) < PS_MIN_##TYPE || creal(unexposedValue) > PS_MAX_##TYPE || \ 874 cimag(unexposedValue) < PS_MIN_##TYPE || cimag(unexposedValue) > PS_MAX_##TYPE) { \ 875 psError(__func__,"The given unexposedValue (%g%+g) is outside of the " \ 876 "image type's range (%g->%g).", \ 877 creal(unexposedValue), cimag(unexposedValue), \ 878 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 995 if (creal(unexposedValue) < PS_MIN_##TYPE || \ 996 creal(unexposedValue) > PS_MAX_##TYPE || \ 997 cimag(unexposedValue) < PS_MIN_##TYPE || \ 998 cimag(unexposedValue) > PS_MAX_##TYPE) { \ 999 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", \ 1000 PS_ERR_BAD_PARAMETER_VALUE, true, \ 1001 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 1002 "unexposedValue", \ 1003 creal(unexposedValue),cimag(unexposedValue), \ 1004 PS_TYPE_##TYPE##_NAME, \ 1005 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 879 1006 psFree(out); \ 880 1007 out = NULL; \ … … 885 1012 float y = dy+(float)row; \ 886 1013 for (int col=0;col<outCols;col++) { \ 887 outRow[col] = p_psImagePixelInterpolate##MODE##_##TYPE(in,dx+(float)col,y,unexposedValue); \ 1014 outRow[col] = p_psImagePixelInterpolate##MODE##_##TYPE( \ 1015 in,dx+(float)col,y,unexposedValue); \ 888 1016 } \ 889 1017 } \ … … 905 1033 PSIMAGE_SHIFT_CASE(MODE,C32); \ 906 1034 PSIMAGE_SHIFT_CASE(MODE,C64); \ 907 default: \ 908 psError(__func__, "Image type (%d) not supported.", type); \ 909 psFree(out); \ 910 out = NULL; \ 1035 \ 1036 default: { \ 1037 char* typeStr; \ 1038 PS_TYPE_NAME(typeStr,type); \ 1039 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \ 1040 PS_ERR_BAD_PARAMETER_TYPE, true, \ 1041 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \ 1042 typeStr); \ 1043 psFree(out); \ 1044 out = NULL; \ 1045 } \ 911 1046 } \ 912 1047 break; … … 917 1052 PSIMAGE_SHIFT_ARBITRARY_CASE(BILINEAR); 918 1053 default: 919 psError(__func__, "Unsupported interpolation mode (%d)", mode); 1054 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", 1055 PS_ERR_BAD_PARAMETER_VALUE, true, 1056 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 1057 mode); 920 1058 psFree(out); 921 1059 out = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
