Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.image
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.io.image
Commits
4120fccf
Commit
4120fccf
authored
8 years ago
by
Manuel Günther
Committed by
André Anjos
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed handling of multi-frame gif (now, the last frame is used); improved Error reporting
parent
e51d59da
No related branches found
No related tags found
1 merge request
!24
Resolve "GIF loading seems to be completely broken"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/io/image/cpp/gif.cpp
+11
-16
11 additions, 16 deletions
bob/io/image/cpp/gif.cpp
with
11 additions
and
16 deletions
bob/io/image/cpp/gif.cpp
+
11
−
16
View file @
4120fccf
...
...
@@ -415,21 +415,17 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
GifByteType
*
extension
;
int
InterlacedOffset
[]
=
{
0
,
4
,
2
,
1
};
// The way Interlaced image should.
int
InterlacedJumps
[]
=
{
8
,
8
,
4
,
2
};
// be read - offsets and jumps...
int
row
,
col
,
width
,
height
,
count
,
ext_code
;
int
row
,
col
,
width
,
height
,
ext_code
;
bool
terminated
=
false
;
bool
image_found
=
false
;
do
{
int
error
=
DGifGetRecordType
(
in_file
.
get
(),
&
record_type
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetRecordType"
,
e
rror
);
GifErrorHandler
(
"DGifGetRecordType"
,
in_file
->
E
rror
);
switch
(
record_type
)
{
case
IMAGE_DESC_RECORD_TYPE
:
if
(
image_found
){
// we already have found an image...
break
;
}
error
=
DGifGetImageDesc
(
in_file
.
get
());
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetImageDesc"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetImageDesc"
,
in_file
->
E
rror
);
row
=
in_file
->
Image
.
Top
;
// Image Position relative to Screen.
col
=
in_file
->
Image
.
Left
;
width
=
in_file
->
Image
.
Width
;
...
...
@@ -441,17 +437,16 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
}
if
(
in_file
->
Image
.
Interlace
)
{
// Need to perform 4 passes on the images:
for
(
int
i
=
count
=
0
;
i
<
4
;
++
i
)
for
(
int
i
=
0
;
i
<
4
;
++
i
)
for
(
int
j
=
row
+
InterlacedOffset
[
i
];
j
<
row
+
height
;
j
+=
InterlacedJumps
[
i
])
{
++
count
;
error
=
DGifGetLine
(
in_file
.
get
(),
&
screen_buffer
[
j
][
col
],
width
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetLine"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetLine"
,
in_file
->
E
rror
);
}
}
else
{
for
(
int
i
=
0
;
i
<
height
;
++
i
)
{
error
=
DGifGetLine
(
in_file
.
get
(),
&
screen_buffer
[
row
++
][
col
],
width
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetLine"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetLine"
,
in_file
->
E
rror
);
}
}
image_found
=
true
;
...
...
@@ -459,10 +454,10 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
case
EXTENSION_RECORD_TYPE
:
// Skip any extension blocks in file:
error
=
DGifGetExtension
(
in_file
.
get
(),
&
ext_code
,
&
extension
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetExtension"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetExtension"
,
in_file
->
E
rror
);
while
(
extension
!=
NULL
)
{
error
=
DGifGetExtensionNext
(
in_file
.
get
(),
&
extension
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetExtensionNext"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"DGifGetExtensionNext"
,
in_file
->
E
rror
);
}
break
;
case
TERMINATE_RECORD_TYPE
:
...
...
@@ -567,15 +562,15 @@ static void im_save_color(const bob::io::base::array::interface& b, boost::share
error
=
EGifPutScreenDesc
(
out_file
.
get
(),
width
,
height
,
ExpNumOfColors
,
0
,
OutputColorMap
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"EGifPutScreenDesc"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"EGifPutScreenDesc"
,
out_file
->
E
rror
);
error
=
EGifPutImageDesc
(
out_file
.
get
(),
0
,
0
,
width
,
height
,
false
,
NULL
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"EGifPutImageDesc"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"EGifPutImageDesc"
,
out_file
->
E
rror
);
GifByteType
*
ptr
=
output_buffer
.
get
();
for
(
int
i
=
0
;
i
<
height
;
++
i
)
{
error
=
EGifPutLine
(
out_file
.
get
(),
ptr
,
width
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"EGifPutImageDesc"
,
e
rror
);
if
(
error
==
GIF_ERROR
)
GifErrorHandler
(
"EGifPutImageDesc"
,
out_file
->
E
rror
);
ptr
+=
width
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment