+ // fill in the data
+ static const unsigned int idbSize = (2 + 2 + 2 + 2 + 1);
+ stream.Read(buf, idbSize);
+ if (stream.LastRead() != idbSize)
+ return wxGIF_INVFORMAT;
+
+ pimg->comment = comment;
+ comment.clear();
+ pimg->left = buf[0] + 256 * buf[1];
+ pimg->top = buf[2] + 256 * buf[3];
+ /*
+ pimg->left = buf[4] + 256 * buf[5];
+ pimg->top = buf[4] + 256 * buf[5];
+ */
+ pimg->w = buf[4] + 256 * buf[5];
+ pimg->h = buf[6] + 256 * buf[7];
+
+ if ( anim )
+ {
+ // some GIF images specify incorrect animation size but we can
+ // still open them if we fix up the animation size, see #9465
+ if ( m_nFrames == 0 )
+ {
+ if ( pimg->w > (unsigned)m_szAnimation.x )
+ m_szAnimation.x = pimg->w;
+ if ( pimg->h > (unsigned)m_szAnimation.y )
+ m_szAnimation.y = pimg->h;
+ }
+ else // subsequent frames
+ {
+ // check that we have valid size
+ if ( (!pimg->w || pimg->w > (unsigned)m_szAnimation.x) ||
+ (!pimg->h || pimg->h > (unsigned)m_szAnimation.y) )
+ {
+ wxLogError(_("Incorrect GIF frame size (%u, %d) for "
+ "the frame #%u"),
+ pimg->w, pimg->h, m_nFrames);
+ return wxGIF_INVFORMAT;
+ }
+ }
+ }