IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2006, 5:22:07 PM (20 years ago)
Author:
Paul Price
Message:

Merging the pslib "additional" functions from the modules into psLib proper.

Added jpeg directory for psImageJpeg.
Changes to build system (configure.ac, and various Makefile.am)

psVectorSmooth: changed API to allow optional output vector
psSparse: changed sizes to type "long"; added "const"
psRegionIsBad: Renamed psRegionIsNaN
psImageBicubeFit: changed sizes to "long"; added a "const"
psLine: changed sizes to "long"
psImageUnbin: description required in SDRS
psImageClippedStats: renaming to psImageBackground; removing static structures; API changed!
psImageFlipX, psImageFlipY merged to psImageFlip
psStringSubstitute: added "const"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r6806 r7380  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-04-06 22:55:18 $
     12 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-06-07 03:22:06 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "psImageGeomManip.h"
    2424
     25#include "psAbort.h"
    2526#include "psError.h"
    2627#include "psImage.h"
     
    878879}
    879880
     881
     882#define FLIP_X_CASE(TYPENAME,TYPE) \
     883case 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) \
     895case 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
     906psImage *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.