Commit e51d59da authored by Manuel Günther's avatar Manuel Günther Committed by André Anjos

Reading all records from the image; use only the first image inside the GIF

parent 1ec669e8
......@@ -416,11 +416,18 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
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;
bool terminated = false;
bool image_found = false;
do{
int error = DGifGetRecordType(in_file.get(), &record_type);
if(error == GIF_ERROR)
GifErrorHandler("DGifGetRecordType", error);
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", error);
row = in_file->Image.Top; // Image Position relative to Screen.
......@@ -447,6 +454,7 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
if(error == GIF_ERROR) GifErrorHandler("DGifGetLine", error);
}
}
image_found = true;
break;
case EXTENSION_RECORD_TYPE:
// Skip any extension blocks in file:
......@@ -458,10 +466,16 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
}
break;
case TERMINATE_RECORD_TYPE:
terminated = true;
break;
default: // Should be trapped by DGifGetRecordType.
break;
}
} while (!terminated);
if (!image_found){
std::runtime_error("GIF: image does not contain an image section");
}
// Lets dump it - set the global variables required and do it:
ColorMapObject *ColorMap = (in_file->Image.ColorMap ? in_file->Image.ColorMap : in_file->SColorMap);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment