Changeset 29544 for trunk/psModules/src/camera/pmFPA_JPEG.c
- Timestamp:
- Oct 25, 2010, 2:46:07 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPA_JPEG.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPA_JPEG.c
r23259 r29544 179 179 psFree(stats); 180 180 181 // default options are: no flip in X or Y, scale bar on bottom 182 psImageJpegOptions *jpegOptions = psImageJpegOptionsAlloc(); 183 181 184 char *colormapName = psMetadataLookupStr(NULL, options, "COLORMAP"); // Name of colour map 182 185 if (!colormapName) { 183 186 colormapName = "-greyscale"; 184 187 } 188 psImageJpegColormapSet(jpegOptions, colormapName); 189 190 // set up the scale options 185 191 char *mode = psMetadataLookupStr(NULL, options, "SCALE.MODE"); // Mode for scaling image 186 192 if (!mode) { … … 195 201 fmax = +6.0; 196 202 } 197 198 float min = 0, max = 0; // Minimum and maximum for stretch199 200 203 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; 203 206 } else if (!strcasecmp(mode, "FRACTION")) { 204 min = fmin*mean;205 max = fmax*mean;207 jpegOptions->min = fmin*mean; 208 jpegOptions->max = fmax*mean; 206 209 } else if (!strcasecmp(mode, "VALUE")) { 207 min = fmin;208 max = fmax;210 jpegOptions->min = fmin; 211 jpegOptions->max = fmax; 209 212 } else { 210 213 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised scaling mode: %s", mode); 211 214 return false; 212 215 } 213 214 if (!isfinite(min) || !isfinite(max)) { 216 if (!isfinite(jpegOptions->min) || !isfinite(jpegOptions->max)) { 215 217 psLogMsg("psModules.jpeg", PS_LOG_WARN, 216 218 "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)) { 227 244 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.
