~saiarcot895/ubuntu/trusty/openscenegraph/armhf-support

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgPlugins/hdr/hdrloader.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Loic Dachary (OuoU)
  • Date: 2009-03-23 14:08:20 UTC
  • mfrom: (1.1.7 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090323140820-i4j3jozdlhyn4lre
rules prevent lib64 with -D LIB_POSTFIX="" (Closes: #517671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <memory.h>
33
33
#include <stdio.h>
34
34
 
 
35
#include <osgDB/FileUtils>
 
36
 
35
37
typedef unsigned char RGBE[4];
36
38
#define R            0
37
39
#define G            1
49
51
bool HDRLoader::isHDRFile(const char *_fileName)
50
52
{
51
53
    FILE *file;
52
 
    file = fopen(_fileName, "rb");
 
54
    file = osgDB::fopen(_fileName, "rb");
53
55
    if (!file)
54
56
        return false;
55
57
 
56
58
    char str[10];
57
 
    fread(str, 10, 1, file);
 
59
    size_t numRead = fread(str, 10, 1, file);
 
60
    
58
61
    fclose(file);
59
62
 
 
63
    if (numRead<10) return false;
 
64
    
60
65
    if (memcmp(str, "#?RADIANCE", 10) && memcmp(str, "#?RGBE", 6))
61
66
        return false;
62
67
 
69
74
    char str[200];
70
75
    FILE *file;
71
76
 
72
 
    file = fopen(_fileName, "rb");
 
77
    file = osgDB::fopen(_fileName, "rb");
73
78
    if (!file)
74
79
        return false;
75
80
 
76
 
    fread(str, 10, 1, file);
77
 
    if (memcmp(str, "#?RADIANCE", 10)) {
 
81
    size_t numRead = fread(str, 10, 1, file);
 
82
 
 
83
    if (numRead<10) 
 
84
    {
 
85
        fclose(file);
 
86
        return false;
 
87
    }
 
88
    
 
89
    if (memcmp(str, "#?RADIANCE", 10))
 
90
    {
78
91
        fseek(file, 0, SEEK_SET);
79
 
        fread(str, 6, 1, file);
80
 
        if (memcmp(str, "#?RGBE", 6)) {
 
92
        numRead = fread(str, 6, 1, file);
 
93
        if (numRead<6 || memcmp(str, "#?RGBE", 6))
 
94
        {
81
95
            fclose(file);
82
96
            return false;
83
97
        }