Welcome, Guest. Please login or register.

Author Topic: Unknown IFF Format / Help me please !!!  (Read 1665 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Unknown IFF Format / Help me please !!!
« on: November 10, 2007, 12:16:32 PM »
The files are corrupt (chunks are shifted when they should be aligned). The corruption is from converting \n linefeeds to \r\n.

This can be undone manually but it needs some work (there can be \r\n sequence naturally in a binary file, so one needs to be careful not just replace all \r\n to \n globally).

If you transferred the files using CrossDos, make sure you don't have the linefeed conversion enabled when moving binary files. Also some combination of bogus mimetypes and certain browsers are known to result in such corruption.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Unknown IFF Format / Help me please !!!
« Reply #1 on: November 10, 2007, 01:12:31 PM »
Ok, here we go:
Code: [Select]
/*
  fix file corrupted by \n -> \r\n conversion

  NOTE: This program will convert all \r\n combinations. If such
  sequence occured in the original file it will be removed aswell.

  Written by Harry Sintonen <sintonen@iki.fi>
  Public Domain
*/

#include <stdio.h>
#include <stdlib.h>
#ifdef MSDOS
#include <fcntl.h>
#include <io.h>
#endif

#define RINGSIZE 2
#define CURR(x) ((x) % RINGSIZE)
#define PREV(x) (((x) - 1) % RINGSIZE)
#define NEXT(x) PREV(x)

int main(void)
{
  int c;
  unsigned char ring[RINGSIZE];
  int rindex = 0, windex = 0;
#ifdef MSDOS
  setmode(fileno(stdin), O_BINARY);
  setmode(fileno(stdout), O_BINARY);
#endif
  while ((c = getchar()) != EOF)
  {
    ring[CURR(windex++)] = c;
    if (windex - rindex == 2)
    {
      if (ring[CURR(rindex)] == '\r' &&
          ring[NEXT(rindex)] == '\n')
      {
        /* Skip this char */
        rindex++;
        continue;
      }
      putchar(ring[CURR(rindex++)]);
    }
  }
  /* Process remaining chars */
  while (CURR(rindex) != CURR(windex))
  {
    if (windex - rindex == 2 &&
        ring[CURR(rindex)] == '\r' &&
        ring[NEXT(rindex)] == '\n')
    {
      /* Skip this char */
      rindex++;
      continue;
    }
    putchar(ring[CURR(rindex++)]);
  }

  return EXIT_SUCCESS;
}

Code: [Select]
$ gcc -Wall -O2 fixlf.c -o fixlf
$ ./fixlf < SEBP_sheet1 | ilbmtoppm -verbose | pnmtopng - > SEBP_sheet1.png
ilbmtoppm: dimensions: 640x512, 2 planes
ilbmtoppm: compression: byterun1
ilbmtoppm: warning - non-square pixels; to fix do a 'pnmscale -yscale 1.1'
ilbmtoppm: unknown chunk type DPPS - skipping
ilbmtoppm: warning - probably shifted 4-bit colormap
ilbmtoppm:     use "-adjustcolors" to scale colormap to 8 bits
ilbmtoppm: input is a 2-plane ILBM
pnmtopng: 3 colors found

And the result:
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Unknown IFF Format / Help me please !!!
« Reply #2 on: November 10, 2007, 01:13:29 PM »
Here are the rest: