Changeset 7380 for trunk/psLib/src/imageops/psImageGeomManip.c
- Timestamp:
- Jun 6, 2006, 5:22:07 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageGeomManip.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageGeomManip.c
r6806 r7380 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-0 4-06 22:55:18$12 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-06-07 03:22:06 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "psImageGeomManip.h" 24 24 25 #include "psAbort.h" 25 26 #include "psError.h" 26 27 #include "psImage.h" … … 878 879 } 879 880 881 882 #define FLIP_X_CASE(TYPENAME,TYPE) \ 883 case TYPENAME: { \ 884 long numRows = input->numRows; \ 885 long numCols = input->numCols; \ 886 for (long i = 0; i < numRows; i++) { \ 887 for (long j = 0; j < numCols; j++) { \ 888 output->data.TYPE[i][j] = input->data.TYPE[i][numCols - j - 1]; \ 889 } \ 890 } \ 891 break; \ 892 } 893 894 #define FLIP_Y_CASE(TYPENAME,TYPE) \ 895 case TYPENAME: { \ 896 long numRows = input->numRows; \ 897 long numCols = input->numCols; \ 898 for (long i = 0; i < numRows; i++) { \ 899 for (long j = 0; j < numCols; j++) { \ 900 output->data.TYPE[i][j] = input->data.TYPE[numRows - i - 1][j]; \ 901 } \ 902 } \ 903 break; \ 904 } 905 906 psImage *psImageFlip(psImage *output, const psImage *input, bool xFlip, bool yFlip) 907 { 908 PS_ASSERT_IMAGE_NON_NULL(input, NULL); 909 910 if (xFlip && yFlip) { 911 // This is equivalent to a 180 degree rotation; 912 return psImageRotate(output, input, M_PI, NAN, PS_INTERPOLATE_BILINEAR); 913 } 914 915 if (!xFlip && !yFlip) { 916 // They want something, so let's give it to them 917 return psImageCopy(output, input, input->type.type); 918 } 919 920 output = psImageRecycle(output, input->numCols, input->numRows, input->type.type); 921 922 if (xFlip) { 923 switch (input->type.type) { 924 FLIP_X_CASE(PS_TYPE_U8, U8); 925 FLIP_X_CASE(PS_TYPE_U16, U16); 926 FLIP_X_CASE(PS_TYPE_U32, U32); 927 FLIP_X_CASE(PS_TYPE_U64, U64); 928 FLIP_X_CASE(PS_TYPE_S8, S8); 929 FLIP_X_CASE(PS_TYPE_S16, S16); 930 FLIP_X_CASE(PS_TYPE_S32, S32); 931 FLIP_X_CASE(PS_TYPE_S64, S64); 932 FLIP_X_CASE(PS_TYPE_F32, F32); 933 FLIP_X_CASE(PS_TYPE_F64, F64); 934 FLIP_X_CASE(PS_TYPE_C32, C32); 935 FLIP_X_CASE(PS_TYPE_C64, C64); 936 default: 937 psFree(output); 938 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown type for input image: %x\n", input->type.type); 939 return NULL; 940 } 941 return output; 942 } 943 if (yFlip) { 944 switch (input->type.type) { 945 FLIP_Y_CASE(PS_TYPE_U8, U8); 946 FLIP_Y_CASE(PS_TYPE_U16, U16); 947 FLIP_Y_CASE(PS_TYPE_U32, U32); 948 FLIP_Y_CASE(PS_TYPE_U64, U64); 949 FLIP_Y_CASE(PS_TYPE_S8, S8); 950 FLIP_Y_CASE(PS_TYPE_S16, S16); 951 FLIP_Y_CASE(PS_TYPE_S32, S32); 952 FLIP_Y_CASE(PS_TYPE_S64, S64); 953 FLIP_Y_CASE(PS_TYPE_F32, F32); 954 FLIP_Y_CASE(PS_TYPE_F64, F64); 955 FLIP_Y_CASE(PS_TYPE_C32, C32); 956 FLIP_Y_CASE(PS_TYPE_C64, C64); 957 default: 958 psFree(output); 959 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown type for input image: %x\n", input->type.type); 960 return NULL; 961 } 962 return output; 963 } 964 965 psAbort(__func__, "Should never get here.\n"); 966 return NULL; 967 }
Note:
See TracChangeset
for help on using the changeset viewer.
