- if (img->flags & FLAG_OVERWRITE) {
- /* Clear the slate. */
- img->currentframe = -1;
- memset(img->framedata[0], 0, img->width * img->height);
- memset(img->mask[0], 0, img->width * img->height);
- } else {
- /* Start over if we are backtracking. */
- if (img->currentframe > frame) {
- memset(img->mask[0], 0, img->width * img->height);
- img->currentframe = -1;
- }
-
- /* We must have previous frame decoded to continue. */
- if (frame > img->currentframe + 1) {
- if (!lbximg_getframe(img, frame-1))
- return NULL;
+ if (!(img->flags & FLAG_RAW)) {
+ /* Skip padding byte, if any */
+ if (img->currentn % 2) {
+ if (img->fops->seek(img->f, 1, SEEK_CUR))
+ return -1;