Fixed reading multiple images from ANI and ICO image files.
In r60852 various 'unneeded' SeekI(0) calls were removed. Examined the changes in that revision and restored all SeekI(0) calls after finding out their removal caused problems with reading more than one image from ICO and ANI files. The image handling code for these formats expects to read from the start of a stream for reading its images (as well as for DoCanRead and DoGetImageCount), regardless of the index of the requested image. Closes #12861. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67671 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -127,6 +127,11 @@ bool wxANIDecoder::DoCanRead(wxInputStream& stream) const
|
||||
wxInt32 anih32;
|
||||
memcpy( &anih32, "anih", 4 );
|
||||
|
||||
if ( stream.SeekI(0) == wxInvalidOffset )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !stream.Read(&FCC1, 4) )
|
||||
return false;
|
||||
|
||||
@@ -220,6 +225,11 @@ bool wxANIDecoder::Load( wxInputStream& stream )
|
||||
wxInt32 seq32;
|
||||
memcpy( &seq32, "seq ", 4 );
|
||||
|
||||
if ( stream.SeekI(0) == wxInvalidOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !stream.Read(&FCC1, 4) )
|
||||
return false;
|
||||
if ( FCC1 != riff32 )
|
||||
|
@@ -1335,6 +1335,11 @@ bool wxICOHandler::SaveFile(wxImage *image,
|
||||
bool wxICOHandler::LoadFile(wxImage *image, wxInputStream& stream,
|
||||
bool verbose, int index)
|
||||
{
|
||||
if (stream.SeekI(0) == wxInvalidOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return DoLoadFile(image, stream, verbose, index);
|
||||
}
|
||||
|
||||
@@ -1423,10 +1428,16 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream,
|
||||
|
||||
int wxICOHandler::DoGetImageCount(wxInputStream& stream)
|
||||
{
|
||||
// It's ok to modify the stream position in this function.
|
||||
|
||||
if (stream.SeekI(0) == wxInvalidOffset)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ICONDIR IconDir;
|
||||
|
||||
if (stream.Read(&IconDir, sizeof(IconDir)).LastRead() != sizeof(IconDir))
|
||||
// it's ok to modify the stream position here
|
||||
return 0;
|
||||
|
||||
return (int)wxUINT16_SWAP_ON_BE(IconDir.idCount);
|
||||
@@ -1492,8 +1503,15 @@ int wxANIHandler::DoGetImageCount(wxInputStream& stream)
|
||||
|
||||
static bool CanReadICOOrCUR(wxInputStream *stream, wxUint16 resourceType)
|
||||
{
|
||||
// It's ok to modify the stream position in this function.
|
||||
|
||||
if ( stream->SeekI(0) == wxInvalidOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ICONDIR iconDir;
|
||||
if ( !stream->Read(&iconDir, sizeof(iconDir)) ) // it's ok to modify the stream position here
|
||||
if ( !stream->Read(&iconDir, sizeof(iconDir)) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user