Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
9e4c6296
Commit
9e4c6296
authored
Aug 13, 2015
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed RGBE images header parsing (fixes #4885)
parent
09b9b0fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
rgbe.cpp
modules/imgcodecs/src/rgbe.cpp
+16
-9
No files found.
modules/imgcodecs/src/rgbe.cpp
View file @
9e4c6296
...
...
@@ -182,6 +182,8 @@ int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info)
info
->
programtype
[
0
]
=
0
;
info
->
gamma
=
info
->
exposure
=
1.0
;
}
// 1. read first line
if
(
fgets
(
buf
,
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]),
fp
)
==
NULL
)
return
rgbe_error
(
rgbe_read_error
,
NULL
);
if
((
buf
[
0
]
!=
'#'
)
||
(
buf
[
1
]
!=
'?'
))
{
...
...
@@ -196,14 +198,19 @@ int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info)
info
->
programtype
[
i
]
=
buf
[
i
+
2
];
}
info
->
programtype
[
i
]
=
0
;
if
(
fgets
(
buf
,
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]),
fp
)
==
0
)
return
rgbe_error
(
rgbe_read_error
,
NULL
);
}
// 2. reading other header lines
bool
hasFormat
=
false
;
for
(;;)
{
if
((
buf
[
0
]
==
0
)
||
(
buf
[
0
]
==
'\n'
))
return
rgbe_error
(
rgbe_format_error
,
"no FORMAT specifier found"
);
if
(
fgets
(
buf
,
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]),
fp
)
==
0
)
return
rgbe_error
(
rgbe_read_error
,
NULL
);
if
(
buf
[
0
]
==
'\n'
)
// end of the header
break
;
else
if
(
buf
[
0
]
==
'#'
)
// commment
continue
;
else
if
(
strcmp
(
buf
,
"FORMAT=32-bit_rle_rgbe
\n
"
)
==
0
)
break
;
/* format found so break out of loop */
hasFormat
=
true
;
else
if
(
info
&&
(
sscanf
(
buf
,
"GAMMA=%g"
,
&
tempf
)
==
1
))
{
info
->
gamma
=
tempf
;
info
->
valid
|=
RGBE_VALID_GAMMA
;
...
...
@@ -212,14 +219,14 @@ int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info)
info
->
exposure
=
tempf
;
info
->
valid
|=
RGBE_VALID_EXPOSURE
;
}
if
(
fgets
(
buf
,
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]),
fp
)
==
0
)
return
rgbe_error
(
rgbe_read_error
,
NULL
);
}
if
(
fgets
(
buf
,
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]),
fp
)
==
0
)
return
rgbe_error
(
rgbe_read_error
,
NULL
);
if
(
strcmp
(
buf
,
"
\n
"
)
!=
0
)
return
rgbe_error
(
rgbe_format_error
,
"missing blank line after FORMAT specifier"
);
if
(
!
hasFormat
)
return
rgbe_error
(
rgbe_format_error
,
"missing FORMAT specifier"
);
// 3. reading resolution string
if
(
fgets
(
buf
,
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]),
fp
)
==
0
)
return
rgbe_error
(
rgbe_read_error
,
NULL
);
if
(
sscanf
(
buf
,
"-Y %d +X %d"
,
height
,
width
)
<
2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment