info-inventor-dev
[Top] [All Lists]

patch for libimage on little-endian systems

To: info-inventor-dev@xxxxxxxxxxx
Subject: patch for libimage on little-endian systems
From: Jean-Francois Panisset <panisset@xxxxxxxxxxx>
Date: Tue, 27 Jan 2004 00:40:29 -0800
Sender: info-inventor-dev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113
It seems that libimage (the library which handles I/O for SGI image files) is creating image with a header which is not byte-swapped on little-endian systems (the native byte order of SGI image files is big-endian). The support for correctly handling endianness is there, but it just forgets to byteswap the header before writing it out. I'm guessing that OpenInventor probably doesn't write images, just reads them (and that part works), but since the OpenInventor source tree is the only place I know where you can find this code (unless you've held on to your IRIX 5.3 IDO CDs with the 4DGifts stuff), I'd like to propose this patch to libimage/open.c for the sake of completeness:

                image->max = 0;
isetname(image,"no name"); image->wastebytes = 0;
!               if( (((unsigned short)*(unsigned char *)&image->imagic) |
!                   ((unsigned short)(*((unsigned char *)&image->imagic+1)) << 
8))
!                   == IMAGIC ) {
!                   image->dorev = 1;
!                   cvtimage((int*)image);
!               } else
!                   image->dorev = 0;
                if (write(f,image,sizeof(IMAGE)) != sizeof(IMAGE)) {
                    free(image);
                    close(f);
                    i_errhdlr("iopen: error on write of image header\n");
                    return NULL;
                }
+               if( image->dorev )
+                   cvtimage((int*)image);
        } else {
                if (file)
                    f = open(file, rw? 2: 0);



<Prev in Thread] Current Thread [Next in Thread>
  • patch for libimage on little-endian systems, Jean-Francois Panisset <=