IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 22, 2010, 11:39:15 AM (16 years ago)
Author:
eugene
Message:

rework jpeg options to allow flips and scale bar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/psModules/src/camera/pmFPA_JPEG.c

    r29514 r29522  
    179179    psFree(stats);
    180180
     181    // default options are: no flip in X or Y, scale bar on bottom
     182    psImageJpegOptions *jpegOptions = psImageJpegOptionsAlloc();
     183
    181184    char *colormapName = psMetadataLookupStr(NULL, options, "COLORMAP"); // Name of colour map
    182185    if (!colormapName) {
    183186        colormapName = "-greyscale";
    184187    }
     188    psImageJpegColormapSet(jpegOptions, colormapName);
     189
     190    // set up the scale options
    185191    char *mode = psMetadataLookupStr(NULL, options, "SCALE.MODE"); // Mode for scaling image
    186192    if (!mode) {
     
    195201        fmax = +6.0;
    196202    }
    197     bool haveBar = psMetadataLookupBool(&status, options, "SCALE.BAR"); // Mode for scaling image
    198     if (!status) {
    199         haveBar = false;
    200     }
    201 
    202     float min = 0, max = 0;             // Minimum and maximum for stretch
    203 
    204203    if (!strcasecmp(mode, "RANGE")) {
    205         min = mean + fmin*delta;
    206         max = mean + fmax*delta;
     204        jpegOptions->min = mean + fmin*delta;
     205        jpegOptions->max = mean + fmax*delta;
    207206    } else if (!strcasecmp(mode, "FRACTION")) {
    208         min = fmin*mean;
    209         max = fmax*mean;
     207        jpegOptions->min = fmin*mean;
     208        jpegOptions->max = fmax*mean;
    210209    } else if (!strcasecmp(mode, "VALUE")) {
    211         min = fmin;
    212         max = fmax;
     210        jpegOptions->min = fmin;
     211        jpegOptions->max = fmax;
    213212    } else {
    214213        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised scaling mode: %s", mode);
    215214        return false;
    216215    }
    217 
    218     if (!isfinite(min) || !isfinite(max)) {
     216    if (!isfinite(jpegOptions->min) || !isfinite(jpegOptions->max)) {
    219217        psLogMsg("psModules.jpeg", PS_LOG_WARN,
    220218                 "The stretch parameters are not both finite --- writing blank jpeg");
    221         min = 0;
    222         max = 1;
    223     }
    224 
    225     psImageJpegOptions *jpegOptions = psImageJpegOptionsAlloc();
    226     psImageJpegColormapSet(jpegOptions, colormapName);
    227 
    228     // default options are: no flip in X or Y, scale bar on bottom
    229     jpegOptions->min = min;
    230     jpegOptions->max = max;
    231 
    232     if (haveBar) {
    233         jpegOptions->showScale = PS_JPEG_SHOWSCALE_BOTTOM;
    234     } else {
    235         jpegOptions->showScale = PS_JPEG_SHOWSCALE_NONE;
     219        jpegOptions->min = 0;
     220        jpegOptions->max = 1;
     221    }
     222
     223    jpegOptions->showScale = PS_JPEG_SHOWSCALE_NONE;
     224    jpegOptions->xFlip = false;
     225    jpegOptions->yFlip = false;
     226   
     227    char *userOptions = psMetadataLookupStr(&status, options, "OPTIONS"); // Mode for scaling image
     228    if (userOptions) {
     229        // just use strstr for now
     230        if (strcasestr(userOptions, "+SB")) {
     231            jpegOptions->showScale = PS_JPEG_SHOWSCALE_BOTTOM;
     232        }
     233        if (strcasestr(userOptions, "-X")) {
     234            jpegOptions->xFlip = true;
     235        }
     236        if (strcasestr(userOptions, "-Y")) {
     237            jpegOptions->yFlip = true;
     238        }
    236239    }
    237240
Note: See TracChangeset for help on using the changeset viewer.