/[xforms]/xforms/image/image_jpeg.c
ViewVC logotype

Diff of /xforms/image/image_jpeg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by leeming, Fri Nov 21 13:23:23 2003 UTC revision 1.6 by leeming, Thu Nov 27 10:29:47 2003 UTC
# Line 68  static unsigned int jpeg_getc(j_decompre Line 68  static unsigned int jpeg_getc(j_decompre
68  static int  static int
69  JPEG_identify(FILE * fp)  JPEG_identify(FILE * fp)
70  {  {
71      char buf[128];      unsigned char buf[128];
72      size_t i;      size_t i;
73    
74      fread(buf, 1, sizeof(buf), fp);      fread(buf, 1, sizeof(buf), fp);
75      rewind(fp);      rewind(fp);
76      buf[sizeof(buf) - 1] = '\0';      buf[sizeof(buf) - 1] = '\0';
77    
78        /* Clive Stubbings.
79         * Test for a JPEG SOI code (0xff, 0xd8) followed by the start of
80         * APP0 segement (0xff).
81         * A 'raw' JPEG will not have the JFIF (JPEG file interchange format)
82         * header but is still readable
83         */
84        if (buf[0] == (unsigned char)0xff &&
85            buf[1] == (unsigned char)0xd8 &&
86            buf[2] == (unsigned char)0xff)
87            return 1;
88    
89      for (i = 0; i < sizeof(buf) - 3 && buf[i] != 'J'; i++)      for (i = 0; i < sizeof(buf) - 3 && buf[i] != 'J'; i++)
90          ;          ;
91    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26