IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 25, 2010, 2:46:07 PM (16 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20100823

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA_JPEG.c

    r23259 r29544  
    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 
    198     float min = 0, max = 0;             // Minimum and maximum for stretch
    199 
    200203    if (!strcasecmp(mode, "RANGE")) {
    201         min = mean + fmin*delta;
    202         max = mean + fmax*delta;
     204        jpegOptions->min = mean + fmin*delta;
     205        jpegOptions->max = mean + fmax*delta;
    203206    } else if (!strcasecmp(mode, "FRACTION")) {
    204         min = fmin*mean;
    205         max = fmax*mean;
     207        jpegOptions->min = fmin*mean;
     208        jpegOptions->max = fmax*mean;
    206209    } else if (!strcasecmp(mode, "VALUE")) {
    207         min = fmin;
    208         max = fmax;
     210        jpegOptions->min = fmin;
     211        jpegOptions->max = fmax;
    209212    } else {
    210213        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised scaling mode: %s", mode);
    211214        return false;
    212215    }
    213 
    214     if (!isfinite(min) || !isfinite(max)) {
     216    if (!isfinite(jpegOptions->min) || !isfinite(jpegOptions->max)) {
    215217        psLogMsg("psModules.jpeg", PS_LOG_WARN,
    216218                 "The stretch parameters are not both finite --- writing blank jpeg");
    217         min = 0;
    218         max = 1;
    219     }
    220 
    221     psImageJpegColormap *map = psImageJpegColormapSet(NULL, colormapName);
    222     if (!map) {
    223         map = psImageJpegColormapSet(NULL, "-greyscale");
    224     }
    225 
    226     if (!psImageJpeg(map, readout->image, file->filename, min, max)) {
     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        }
     239    }
     240
     241    // NOTE: we can overlay the location of the stars from the readout by passing a bDrawBuffer to this function
     242
     243    if (!psImageJpeg(jpegOptions, readout->image, NULL, file->filename)) {
    227244        psError(PS_ERR_UNKNOWN, false, "Unable to write JPEG image");
    228         psFree(map);
    229         return false;
    230     }
    231 
    232     psFree(map);
    233     return true;
    234 }
     245        psFree(jpegOptions);
     246        return false;
     247    }
     248
     249    psFree(jpegOptions);
     250    return true;
     251}
Note: See TracChangeset for help on using the changeset viewer.