~jderose/ubuntu/saucy/darktable/merge-1.2.3

« back to all changes in this revision

Viewing changes to src/common/imageio_pfm.c

  • Committer: Package Import Robot
  • Author(s): David Bremner
  • Date: 2013-05-29 07:12:24 UTC
  • mfrom: (8.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130529071224-gmilsf4ozn2hwqmm
Tags: 1.2.1-1
* New upstream bugfix release (Closes: #710207).
  - Blend mode "vividlight" should work for NaNs
  - Whitebalance is now relative to daylight, not to camera white balance
  - Now importing folder via key accelerator is supported.
  - Only one temperature slider in white balance
  - Some fixes to the zoom behaviour in darkroom mode
  - Fix some possible deadlocks, memory leaks and null pointer dereferences

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <stdio.h>
25
25
#include <stdlib.h>
26
 
#include <string.h>
 
26
#include <strings.h>
27
27
#include <math.h>
28
28
#include <assert.h>
29
29
 
31
31
{
32
32
  const char *ext = filename + strlen(filename);
33
33
  while(*ext != '.' && ext > filename) ext--;
34
 
  if(strncmp(ext, ".pfm", 4) && strncmp(ext, ".PFM", 4) && strncmp(ext, ".Pfm", 4)) return DT_IMAGEIO_FILE_CORRUPTED;
 
34
  if(strcasecmp(ext, ".pfm")) return DT_IMAGEIO_FILE_CORRUPTED;
35
35
  FILE *f = fopen(filename, "rb");
36
36
  if(!f) return DT_IMAGEIO_FILE_CORRUPTED;
37
37
  int ret = 0;
53
53
  if(cols == 3)
54
54
  {
55
55
    ret = fread(buf, 3*sizeof(float), img->width*img->height, f);
56
 
    for(int i=img->width*img->height-1; i>=0; i--) for(int c=0; c<3; c++) buf[4*i+c] = fmaxf(0.0f, fminf(10000.0, buf[3*i+c]));
 
56
    for(int i=img->width*img->height-1; i>=0; i--) for(int c=0; c<3; c++) buf[4*i+c] = fmaxf(0.0f, fminf(FLT_MAX, buf[3*i+c]));
57
57
  }
58
58
  else for(int j=0; j < img->height; j++)
59
59
      for(int i=0; i < img->width; i++)