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
93d46995
Commit
93d46995
authored
Jun 06, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed reading of certain BMP files
parent
c6415bf9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
grfmt_bmp.cpp
modules/highgui/src/grfmt_bmp.cpp
+11
-6
grfmt_bmp.hpp
modules/highgui/src/grfmt_bmp.hpp
+1
-0
No files found.
modules/highgui/src/grfmt_bmp.cpp
View file @
93d46995
...
@@ -103,7 +103,7 @@ bool BmpDecoder::readHeader()
...
@@ -103,7 +103,7 @@ bool BmpDecoder::readHeader()
int
clrused
=
m_strm
.
getDWord
();
int
clrused
=
m_strm
.
getDWord
();
m_strm
.
skip
(
size
-
36
);
m_strm
.
skip
(
size
-
36
);
if
(
m_width
>
0
&&
m_height
>
0
&&
if
(
m_width
>
0
&&
m_height
!=
0
&&
(((
m_bpp
==
1
||
m_bpp
==
4
||
m_bpp
==
8
||
(((
m_bpp
==
1
||
m_bpp
==
4
||
m_bpp
==
8
||
m_bpp
==
24
||
m_bpp
==
32
)
&&
m_rle_code
==
BMP_RGB
)
||
m_bpp
==
24
||
m_bpp
==
32
)
&&
m_rle_code
==
BMP_RGB
)
||
(
m_bpp
==
16
&&
(
m_rle_code
==
BMP_RGB
||
m_rle_code
==
BMP_BITFIELDS
))
||
(
m_bpp
==
16
&&
(
m_rle_code
==
BMP_RGB
||
m_rle_code
==
BMP_BITFIELDS
))
||
...
@@ -143,7 +143,7 @@ bool BmpDecoder::readHeader()
...
@@ -143,7 +143,7 @@ bool BmpDecoder::readHeader()
m_bpp
=
m_strm
.
getDWord
()
>>
16
;
m_bpp
=
m_strm
.
getDWord
()
>>
16
;
m_rle_code
=
BMP_RGB
;
m_rle_code
=
BMP_RGB
;
if
(
m_width
>
0
&&
m_height
>
0
&&
if
(
m_width
>
0
&&
m_height
!=
0
&&
(
m_bpp
==
1
||
m_bpp
==
4
||
m_bpp
==
8
||
(
m_bpp
==
1
||
m_bpp
==
4
||
m_bpp
==
8
||
m_bpp
==
24
||
m_bpp
==
32
))
m_bpp
==
24
||
m_bpp
==
32
))
{
{
...
@@ -168,6 +168,9 @@ bool BmpDecoder::readHeader()
...
@@ -168,6 +168,9 @@ bool BmpDecoder::readHeader()
}
}
m_type
=
iscolor
?
CV_8UC3
:
CV_8UC1
;
m_type
=
iscolor
?
CV_8UC3
:
CV_8UC1
;
m_origin
=
m_height
>
0
?
IPL_ORIGIN_BL
:
IPL_ORIGIN_TL
;
m_height
=
std
::
abs
(
m_height
);
if
(
!
result
)
if
(
!
result
)
{
{
m_offset
=
-
1
;
m_offset
=
-
1
;
...
@@ -192,12 +195,14 @@ bool BmpDecoder::readData( Mat& img )
...
@@ -192,12 +195,14 @@ bool BmpDecoder::readData( Mat& img )
if
(
m_offset
<
0
||
!
m_strm
.
isOpened
())
if
(
m_offset
<
0
||
!
m_strm
.
isOpened
())
return
false
;
return
false
;
data
+=
(
m_height
-
1
)
*
step
;
if
(
m_origin
==
IPL_ORIGIN_BL
)
step
=
-
step
;
{
data
+=
(
m_height
-
1
)
*
step
;
step
=
-
step
;
}
AutoBuffer
<
uchar
>
_src
,
_bgr
;
AutoBuffer
<
uchar
>
_src
,
_bgr
;
if
(
(
m_bpp
!=
24
||
!
color
)
)
_src
.
allocate
(
src_pitch
+
32
);
_src
.
allocate
(
src_pitch
+
32
);
if
(
!
color
)
if
(
!
color
)
{
{
...
...
modules/highgui/src/grfmt_bmp.hpp
View file @
93d46995
...
@@ -75,6 +75,7 @@ protected:
...
@@ -75,6 +75,7 @@ protected:
RLByteStream
m_strm
;
RLByteStream
m_strm
;
PaletteEntry
m_palette
[
256
];
PaletteEntry
m_palette
[
256
];
int
m_origin
;
int
m_bpp
;
int
m_bpp
;
int
m_offset
;
int
m_offset
;
BmpCompression
m_rle_code
;
BmpCompression
m_rle_code
;
...
...
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