]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Removed support for legacy image formats
authorTill Kamppeter <till.kamppeter@gmail.com>
Sun, 4 Sep 2022 12:59:33 +0000 (14:59 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sun, 4 Sep 2022 12:59:33 +0000 (14:59 +0200)
Removed support for the legacy image formats GIF, Photo CD, X Pixmap,
X Bitmap, PNM (Portable Anymap/Bitmap/Graymap/Pixmap), BMP, SGI RGB,
Sun Raster. This is to avoid the requirement to maintain gthe code
supporting these mostly obsolete image formats.

JPEG, PNG, and TIFF are still available.

Makefile.am
cupsfilters/image-gif.c [deleted file]
cupsfilters/image-photocd.c [deleted file]
cupsfilters/image-pix.c [deleted file]
cupsfilters/image-pnm.c [deleted file]
cupsfilters/image-private.h
cupsfilters/image-sgi.c [deleted file]
cupsfilters/image-sun.c [deleted file]
cupsfilters/image.c
mime/cupsfilters-individual.convs
mime/cupsfilters-universal.convs

index d57df82e477c9640b3c5d95015d2b080c3b35086..c6d56f080c9f44b2f40f478619bf6d821dda779c 100644 (file)
@@ -283,17 +283,10 @@ libcupsfilters_la_SOURCES = \
        cupsfilters/ghostscript.c \
        cupsfilters/ieee1284.c \
        cupsfilters/image.c \
-       cupsfilters/image-bmp.c \
        cupsfilters/image-colorspace.c \
-       cupsfilters/image-gif.c \
        cupsfilters/image-jpeg.c \
-       cupsfilters/image-photocd.c \
-       cupsfilters/image-pix.c \
        cupsfilters/image-png.c \
-       cupsfilters/image-pnm.c \
        cupsfilters/image-private.h \
-       cupsfilters/image-sgi.c \
-       cupsfilters/image-sun.c \
        cupsfilters/image-tiff.c \
        cupsfilters/image-zoom.c \
        cupsfilters/imagetopdf.c \
diff --git a/cupsfilters/image-gif.c b/cupsfilters/image-gif.c
deleted file mode 100644 (file)
index ecc1944..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-/*
- *   GIF image routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadGIF() - Read a GIF image file.
- *   gif_get_block()     - Read a GIF data block...
- *   gif_get_code()      - Get a LZW code from the file...
- *   gif_read_cmap()     - Read the colormap from a GIF file...
- *   gif_read_image()    - Read a GIF image stream...
- *   gif_read_lzw()      - Read a byte from the LZW stream...
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-
-
-/*
- * GIF definitions...
- */
-
-#define GIF_INTERLACE  0x40
-#define GIF_COLORMAP   0x80
-#define GIF_MAX_BITS   12
-
-typedef cf_ib_t        gif_cmap_t[256][4];
-typedef short          gif_table_t[4096];
-
-
-/*
- * Local globals...
- */
-
-static int     gif_eof = 0;            /* Did we hit EOF? */
-
-
-/*
- * Local functions...
- */
-
-static int     gif_get_block(FILE *fp, unsigned char *buffer);
-static int     gif_get_code (FILE *fp, int code_size, int first_time);
-static int     gif_read_cmap(FILE *fp, int ncolors, gif_cmap_t cmap,
-                             int *gray);
-static int     gif_read_image(FILE *fp, cf_image_t *img, gif_cmap_t cmap,
-                              int interlace);
-static int     gif_read_lzw(FILE *fp, int first_time, int input_code_size);
-
-
-/*
- * '_cfImageReadGIF()' - Read a GIF image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadGIF(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  unsigned char        buf[1024];              /* Input buffer */
-  gif_cmap_t   cmap;                   /* Colormap */
-  int          i,                      /* Looping var */
-               bpp,                    /* Bytes per pixel */
-               gray,                   /* Grayscale image? */
-               ncolors,                /* Bits per pixel */
-               transparent;            /* Transparent color index */
-
-
- /*
-  * GIF files are either grayscale or RGB - no CMYK...
-  */
-
-  if (primary == CF_IMAGE_RGB_CMYK)
-    primary = CF_IMAGE_RGB;
-
- /*
-  * Read the header; we already know it is a GIF file...
-  */
-
-  if (fread(buf, 13, 1, fp) == 0 && ferror(fp))
-    DEBUG_printf(("Error reading file!"));
-
-  img->xsize = (buf[7] << 8) | buf[6];
-  img->ysize = (buf[9] << 8) | buf[8];
-  ncolors    = 2 << (buf[10] & 0x07);
-  gray       = primary == CF_IMAGE_BLACK || primary == CF_IMAGE_WHITE;
-
-  if (buf[10] & GIF_COLORMAP)
-    if (gif_read_cmap(fp, ncolors, cmap, &gray))
-    {
-      fclose(fp);
-      return (-1);
-    }
-
-  transparent = -1;
-
-  for (;;)
-  {
-    switch (getc(fp))
-    {
-      case ';' :       /* End of image */
-          fclose(fp);
-          return (-1);         /* Early end of file */
-
-      case '!' :       /* Extension record */
-          buf[0] = getc(fp);
-          if (buf[0] == 0xf9)  /* Graphic Control Extension */
-          {
-            gif_get_block(fp, buf);
-            if (buf[0] & 1)    /* Get transparent color index */
-              transparent = buf[3];
-          }
-
-          while (gif_get_block(fp, buf) != 0)
-          {
-            if(gif_eof)
-            {
-              return (-1);
-            }
-          }
-          break;
-
-      case ',' :       /* Image data */
-          if (fread(buf, 9, 1, fp) == 0 && ferror(fp))
-           DEBUG_printf(("Error reading file!"));
-
-          if (buf[8] & GIF_COLORMAP)
-          {
-            ncolors = 2 << (buf[8] & 0x07);
-            gray = primary == CF_IMAGE_BLACK || primary == CF_IMAGE_WHITE;
-
-           if (gif_read_cmap(fp, ncolors, cmap, &gray))
-           {
-              fclose(fp);
-             return (-1);
-           }
-         }
-
-          if (transparent >= 0)
-          {
-           /*
-            * Make transparent color white...
-            */
-
-            cmap[transparent][0] = 255;
-            cmap[transparent][1] = 255;
-            cmap[transparent][2] = 255;
-          }
-
-         if (gray)
-         {
-           switch (secondary)
-           {
-              case CF_IMAGE_CMYK :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageWhiteToCMYK(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_CMY :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageWhiteToCMY(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_BLACK :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageWhiteToBlack(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_WHITE :
-                 break;
-              case CF_IMAGE_RGB :
-              case CF_IMAGE_RGB_CMYK :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageWhiteToRGB(cmap[i], cmap[i], 1);
-                 break;
-           }
-
-            img->colorspace = secondary;
-         }
-         else
-         {
-           if (hue != 0 || saturation != 100)
-              for (i = ncolors - 1; i >= 0; i --)
-               cfImageRGBAdjust(cmap[i], 1, saturation, hue);
-
-           switch (primary)
-           {
-              case CF_IMAGE_CMYK :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageRGBToCMYK(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_CMY :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageRGBToCMY(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_BLACK :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageRGBToBlack(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_WHITE :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageRGBToWhite(cmap[i], cmap[i], 1);
-                 break;
-              case CF_IMAGE_RGB :
-              case CF_IMAGE_RGB_CMYK :
-                 for (i = ncolors - 1; i >= 0; i --)
-                   cfImageRGBToRGB(cmap[i], cmap[i], 1);
-                 break;
-           }
-
-            img->colorspace = primary;
-         }
-
-          if (lut)
-         {
-           bpp = cfImageGetDepth(img);
-
-            for (i = ncolors - 1; i >= 0; i --)
-              cfImageLut(cmap[i], bpp, lut);
-         }
-
-          img->xsize = (buf[5] << 8) | buf[4];
-          img->ysize = (buf[7] << 8) | buf[6];
-
-         /*
-         * Check the dimensions of the image; since the dimensions are
-         * a 16-bit integer we just need to check for 0...
-         */
-
-          if (img->xsize == 0 || img->ysize == 0)
-         {
-           DEBUG_printf(("DEBUG: Bad GIF image dimensions: %dx%d\n",
-                         img->xsize, img->ysize));
-           fclose(fp);
-           return (1);
-         }
-
-         i = gif_read_image(fp, img, cmap, buf[8] & GIF_INTERLACE);
-          fclose(fp);
-          return (i);
-    }
-  }
-}
-
-
-/*
- * 'gif_get_block()' - Read a GIF data block...
- */
-
-static int                             /* O - Number characters read */
-gif_get_block(FILE          *fp,       /* I - File to read from */
-             unsigned char *buf)       /* I - Input buffer */
-{
-  int  count;                          /* Number of character to read */
-
-
- /*
-  * Read the count byte followed by the data from the file...
-  */
-
-  if ((count = getc(fp)) == EOF)
-  {
-    gif_eof = 1;
-    return (-1);
-  }
-  else if (count == 0)
-    gif_eof = 1;
-  else if (fread(buf, 1, count, fp) < count)
-  {
-    gif_eof = 1;
-    return (-1);
-  }
-  else
-    gif_eof = 0;
-
-  return (count);
-}
-
-
-/*
- * 'gif_get_code()' - Get a LZW code from the file...
- */
-
-static int                             /* O - LZW code */
-gif_get_code(FILE *fp,                 /* I - File to read from */
-            int  code_size,            /* I - Size of code in bits */
-            int  first_time)           /* I - 1 = first time, 0 = not first time */
-{
-  unsigned             i, j,           /* Looping vars */
-                       ret;            /* Return value */
-  int                  count;          /* Number of bytes read */
-  static unsigned char buf[280];       /* Input buffer */
-  static unsigned      curbit,         /* Current bit */
-                       lastbit,        /* Last bit in buffer */
-                       done,           /* Done with this buffer? */
-                       last_byte;      /* Last byte in buffer */
-  static const unsigned char bits[8] = /* Bit masks for codes */
-                       {
-                         0x01, 0x02, 0x04, 0x08,
-                         0x10, 0x20, 0x40, 0x80
-                       };
-
-
-  if (first_time)
-  {
-   /*
-    * Just initialize the input buffer...
-    */
-
-    curbit    = 0;
-    lastbit   = 0;
-    last_byte = 0;
-    done      = 0;
-
-    return (0);
-  }
-
-  if ((curbit + code_size) >= lastbit)
-  {
-   /*
-    * Don't have enough bits to hold the code...
-    */
-
-    if (done)
-      return (-1);     /* Sorry, no more... */
-
-   /*
-    * Move last two bytes to front of buffer...
-    */
-
-    if (last_byte > 1)
-    {
-      buf[0]    = buf[last_byte - 2];
-      buf[1]    = buf[last_byte - 1];
-      last_byte = 2;
-    }
-    else if (last_byte == 1)
-    {
-      buf[0]    = buf[last_byte - 1];
-      last_byte = 1;
-    }
-
-   /*
-    * Read in another buffer...
-    */
-
-    if ((count = gif_get_block(fp, buf + last_byte)) <= 0)
-    {
-     /*
-      * Whoops, no more data!
-      */
-
-      done = 1;
-      return (-1);
-    }
-
-   /*
-    * Update buffer state...
-    */
-
-    curbit    = (curbit - lastbit) + 8 * last_byte;
-    last_byte += count;
-    lastbit   = last_byte * 8;
-  }
-
-  for (ret = 0, i = curbit + code_size - 1, j = code_size;
-       j > 0;
-       i --, j --)
-    ret = (ret << 1) | ((buf[i / 8] & bits[i & 7]) != 0);
-
-  curbit += code_size;
-
-  return ret;
-}
-
-
-/*
- * 'gif_read_cmap()' - Read the colormap from a GIF file...
- */
-
-static int                             /* O - -1 on error, 0 on success */
-gif_read_cmap(FILE       *fp,          /* I - File to read from */
-             int        ncolors,       /* I - Number of colors in file */
-             gif_cmap_t cmap,          /* O - Colormap information */
-             int        *gray)         /* IO - Is the image grayscale? */
-{
-  int  i;                              /* Looping var */
-
-
- /*
-  * Read the colormap...
-  */
-
-  for (i = 0; i < ncolors; i ++)
-    if (fread(cmap[i], 3, 1, fp) < 1)
-      return (-1);
-
- /*
-  * Check to see if the colormap is a grayscale ramp...
-  */
-
-  for (i = 0; i < ncolors; i ++)
-    if (cmap[i][0] != cmap[i][1] || cmap[i][1] != cmap[i][2])
-      break;
-
-  if (i == ncolors)
-  {
-    *gray = 1;
-    return (0);
-  }
-
- /*
-  * If this needs to be a grayscale image, convert the RGB values to
-  * luminance values...
-  */
-
-  if (*gray)
-    for (i = 0; i < ncolors; i ++)
-      cmap[i][0] = (cmap[i][0] * 31 + cmap[i][1] * 61 + cmap[i][2] * 8) / 100;
-
-  return (0);
-}
-
-
-/*
- * 'gif_read_image()' - Read a GIF image stream...
- */
-
-static int                             /* I - 0 = success, -1 = failure */
-gif_read_image(FILE         *fp,       /* I - Input file */
-              cf_image_t *img, /* I - Image pointer */
-              gif_cmap_t   cmap,       /* I - Colormap */
-              int          interlace)  /* I - Non-zero = interlaced image */
-{
-  unsigned char                code_size;      /* Code size */
-  cf_ib_t              *pixels,        /* Pixel buffer */
-                       *temp;          /* Current pixel */
-  int                  xpos,           /* Current X position */
-                       ypos,           /* Current Y position */
-                       pass;           /* Current pass */
-  int                  pixel;          /* Current pixel */
-  int                  bpp;            /* Bytes per pixel */
-  static const int     xpasses[4] =    /* X interleaving */
-                       { 8, 8, 4, 2 },
-                       ypasses[5] =    /* Y interleaving */
-                       { 0, 4, 2, 1, 999999 };
-
-
-  bpp       = cfImageGetDepth(img);
-  pixels    = calloc(bpp, img->xsize);
-  xpos      = 0;
-  ypos      = 0;
-  pass      = 0;
-  code_size = getc(fp);
-
-  if (!pixels)
-    return (-1);
-
-  if (code_size > GIF_MAX_BITS || gif_read_lzw(fp, 1, code_size) < 0)
-  {
-    free(pixels);
-    return (-1);
-  }
-
-  temp = pixels;
-  while ((pixel = gif_read_lzw(fp, 0, code_size)) >= 0)
-  {
-    switch (bpp)
-    {
-      case 4 :
-          temp[3] = cmap[pixel][3];
-      case 3 :
-          temp[2] = cmap[pixel][2];
-      case 2 :
-          temp[1] = cmap[pixel][1];
-      default :
-          temp[0] = cmap[pixel][0];
-    }
-
-    xpos ++;
-    temp += bpp;
-    if (xpos == img->xsize)
-    {
-      int res = _cfImagePutRow(img, 0, ypos, img->xsize, pixels);
-      if(res)
-      {
-        return (-1);
-      }
-      xpos = 0;
-      temp = pixels;
-
-      if (interlace)
-      {
-        ypos += xpasses[pass];
-
-        if (ypos >= img->ysize)
-       {
-         pass ++;
-
-          ypos = ypasses[pass];
-       }
-      }
-      else
-       ypos ++;
-    }
-
-    if (ypos >= img->ysize)
-      break;
-  }
-
-  free(pixels);
-
-  return (0);
-}
-
-
-/*
- * 'gif_read_lzw()' - Read a byte from the LZW stream...
- */
-
-static int                             /* I - Byte from stream */
-gif_read_lzw(FILE *fp,                 /* I - File to read from */
-            int  first_time,           /* I - 1 = first time, 0 = not first time */
-            int  input_code_size)      /* I - Code size in bits */
-{
-  int                  i,              /* Looping var */
-                       code,           /* Current code */
-                       incode;         /* Input code */
-  static short         fresh = 0,      /* 1 = empty buffers */
-                       code_size,      /* Current code size */
-                       set_code_size,  /* Initial code size set */
-                       max_code,       /* Maximum code used */
-                       max_code_size,  /* Maximum code size */
-                       firstcode,      /* First code read */
-                       oldcode,        /* Last code read */
-                       clear_code,     /* Clear code for LZW input */
-                       end_code,       /* End code for LZW input */
-                       *stack = NULL,  /* Output stack */
-                       *sp;            /* Current stack pointer */
-  static gif_table_t   *table = NULL;  /* String table */
-
-
-  if (first_time)
-  {
-   /*
-    * Setup LZW state...
-    */
-
-    set_code_size = input_code_size;
-    code_size     = set_code_size + 1;
-    clear_code    = 1 << set_code_size;
-    end_code      = clear_code + 1;
-    max_code_size = 2 * clear_code;
-    max_code      = clear_code + 2;
-
-   /*
-    * Allocate memory for buffers...
-    */
-
-    if (table == NULL)
-      table = calloc(2, sizeof(gif_table_t));
-
-    if (table == NULL)
-      return (-1);
-
-    if (stack == NULL)
-      stack = calloc(8192, sizeof(short));
-
-    if (stack == NULL)
-      return (-1);
-
-   /*
-    * Initialize input buffers...
-    */
-
-    gif_get_code(fp, 0, 1);
-
-   /*
-    * Wipe the decompressor table (already mostly 0 due to the calloc above...)
-    */
-
-    fresh = 1;
-
-    for (i = 1; i < clear_code; i ++)
-      table[1][i] = i;
-
-    sp = stack;
-
-    return (0);
-  }
-  else if (fresh)
-  {
-    fresh = 0;
-
-    do
-    {
-      firstcode = oldcode = gif_get_code(fp, code_size, 0);
-    }
-    while (firstcode == clear_code);
-
-    return (firstcode & 255);
-  }
-  else if (!table)
-    return (0);
-
-  if (sp > stack)
-    return ((*--sp) & 255);
-
-  while ((code = gif_get_code(fp, code_size, 0)) >= 0)
-  {
-    if (code == clear_code)
-    {
-     /*
-      * Clear/reset the compression table...
-      */
-
-      memset(table, 0, 2 * sizeof(gif_table_t));
-      for (i = 1; i < clear_code; i ++)
-       table[1][i] = i;
-
-      code_size     = set_code_size + 1;
-      max_code_size = 2 * clear_code;
-      max_code      = clear_code + 2;
-
-      sp = stack;
-
-      firstcode = oldcode = gif_get_code(fp, code_size, 0);
-
-      return (firstcode & 255);
-    }
-    else if (code == end_code || code > max_code)
-    {
-      unsigned char    buf[260];       /* Block buffer */
-
-      if (!gif_eof)
-        while (gif_get_block(fp, buf) > 0);
-
-      return (-2);
-    }
-
-    incode = code;
-
-    if (code == max_code)
-    {
-      if (sp < (stack + 8192))
-       *sp++ = firstcode;
-
-      code = oldcode;
-    }
-
-    while (code >= clear_code && sp < (stack + 8192))
-    {
-      *sp++ = table[1][code];
-      if (code == table[0][code])
-       return (255);
-
-      code = table[0][code];
-    }
-
-    if (sp < (stack + 8192))
-      *sp++ = firstcode = table[1][code];
-
-    code = max_code;
-
-    if (code < 4096)
-    {
-      table[0][code] = oldcode;
-      table[1][code] = firstcode;
-      max_code ++;
-
-      if (max_code >= max_code_size && max_code_size < 4096)
-      {
-       max_code_size *= 2;
-       code_size ++;
-      }
-    }
-
-    oldcode = incode;
-
-    if (sp > stack)
-      return ((*--sp) & 255);
-  }
-
-  return (code & 255);
-}
-
diff --git a/cupsfilters/image-photocd.c b/cupsfilters/image-photocd.c
deleted file mode 100644 (file)
index 61b7cd6..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- *   PhotoCD routines for CUPS.
- *
- *   PhotoCD support is currently limited to the 768x512 base image, which
- *   is only YCC encoded.  Support for the higher resolution images will
- *   require a lot of extra code...
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2006 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadPhotoCD() - Read a PhotoCD image file.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-
-
-/*
- * '_cfImageReadPhotoCD()' - Read a PhotoCD image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadPhotoCD(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  int          x, y;                   /* Looping vars */
-  int          xdir,                   /* X direction */
-               xstart;                 /* X starting point */
-  int          bpp;                    /* Bytes per pixel */
-  int          pass;                   /* Pass number */
-  int          rotation;               /* 0 for 768x512, 1 for 512x768 */
-  int          temp,                   /* Adjusted luminance */
-               temp2,                  /* Red, green, and blue values */
-               cb, cr;                 /* Adjusted chroma values */
-  cf_ib_t      *in,                    /* Input (YCC) pixels */
-               *iy,                    /* Luminance */
-               *icb,                   /* Blue chroma */
-               *icr,                   /* Red chroma */
-               *rgb,                   /* RGB */
-               *rgbptr,                /* Pointer into RGB data */
-               *out;                   /* Output pixels */
-
-
-  (void)secondary;
-
- /*
-  * Get the image orientation...
-  */
-
-  fseek(fp, 72, SEEK_SET);
-  rotation = (getc(fp) & 63) != 8;
-
- /*
-  * Seek to the start of the base image...
-  */
-
-  fseek(fp, 0x30000, SEEK_SET);
-
- /*
-  * Allocate and initialize...
-  */
-
-  img->colorspace = (primary == CF_IMAGE_RGB_CMYK) ? CF_IMAGE_RGB : primary;
-  img->xppi       = 200;
-  img->yppi       = 200;
-
-  if (rotation)
-  {
-    img->xsize = 512;
-    img->ysize = 768;
-  }
-  else
-  {
-    img->xsize = 768;
-    img->ysize = 512;
-  }
-
-  cfImageSetMaxTiles(img, 0);
-
-  bpp = cfImageGetDepth(img);
-
-  if ((in = malloc(768 * 3)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  if ((out = malloc(768 * bpp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    free(in);
-    return (1);
-  }
-
-  if (bpp > 1)
-  {
-    if ((rgb = malloc(768 * 3)) == NULL)
-    {
-      DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-      fclose(fp);
-      free(in);
-      free(out);
-      return (1);
-    }
-  }
-  else
-    rgb = NULL;
-
-  if (rotation)
-  {
-    xstart = 767 * bpp;
-    xdir   = -2 * bpp;
-  }
-  else
-  {
-    xstart = 0;
-    xdir   = 0;
-  }
-
- /*
-  * Read the image file...
-  */
-
-  for (y = 0; y < 512; y += 2)
-  {
-   /*
-    * Grab the next two scanlines:
-    *
-    *     YYYYYYYYYYYYYYY...
-    *     YYYYYYYYYYYYYYY...
-    *     CbCbCb...CrCrCr...
-    */
-
-    if (fread(in, 1, 768 * 3, fp) < (768 * 3))
-    {
-     /*
-      * Couldn't read a row of data - return an error!
-      */
-
-      free(in);
-      free(out);
-
-      if (bpp > 1)
-        free(rgb);
-
-      return (-1);
-    }
-
-   /*
-    * Process the two scanlines...
-    */
-
-    for (pass = 0, iy = in; pass < 2; pass ++)
-    {
-      if (bpp == 1)
-      {
-       /*
-       * Just extract the luminance channel from the line and put it
-       * in the image...
-       */
-
-        if (primary == CF_IMAGE_BLACK)
-       {
-         if (rotation)
-         {
-           for (rgbptr = out + xstart, x = 0; x < 768; x ++)
-             *rgbptr-- = 255 - *iy++;
-
-           if (lut)
-             cfImageLut(out, 768, lut);
-
-            _cfImagePutCol(img, 511 - y - pass, 0, 768, out);
-         }
-         else
-         {
-            cfImageWhiteToBlack(iy, out, 768);
-
-           if (lut)
-             cfImageLut(out, 768, lut);
-
-            _cfImagePutRow(img, 0, y + pass, 768, out);
-            iy += 768;
-         }
-       }
-       else if (rotation)
-       {
-         for (rgbptr = out + xstart, x = 0; x < 768; x ++)
-           *rgbptr-- = 255 - *iy++;
-
-         if (lut)
-           cfImageLut(out, 768, lut);
-
-          _cfImagePutCol(img, 511 - y - pass, 0, 768, out);
-       }
-       else
-       {
-         if (lut)
-           cfImageLut(iy, 768, lut);
-
-          _cfImagePutRow(img, 0, y + pass, 768, iy);
-          iy += 768;
-       }
-      }
-      else
-      {
-       /*
-        * Convert YCbCr to RGB...  While every pixel gets a luminance
-       * value, adjacent pixels share chroma information.
-       */
-
-        cb = cr = 0.0f;
-
-        for (x = 0, rgbptr = rgb + xstart, icb = in + 1536, icr = in + 1920;
-            x < 768;
-            x ++, iy ++, rgbptr += xdir)
-       {
-         if (!(x & 1))
-         {
-           cb = (float)(*icb - 156);
-           cr = (float)(*icr - 137);
-         }
-
-          temp = 92241 * (*iy);
-
-         temp2 = (temp + 86706 * cr) / 65536;
-         if (temp2 < 0)
-           *rgbptr++ = 0;
-         else if (temp2 > 255)
-           *rgbptr++ = 255;
-         else
-           *rgbptr++ = temp2;
-
-          temp2 = (temp - 25914 * cb - 44166 * cr) / 65536;
-         if (temp2 < 0)
-           *rgbptr++ = 0;
-         else if (temp2 > 255)
-           *rgbptr++ = 255;
-         else
-           *rgbptr++ = temp2;
-
-          temp2 = (temp + 133434 * cb) / 65536;
-         if (temp2 < 0)
-           *rgbptr++ = 0;
-         else if (temp2 > 255)
-           *rgbptr++ = 255;
-         else
-           *rgbptr++ = temp2;
-
-         if (x & 1)
-         {
-           icb ++;
-           icr ++;
-         }
-       }
-
-       /*
-        * Adjust the hue and saturation if needed...
-       */
-
-       if (saturation != 100 || hue != 0)
-         cfImageRGBAdjust(rgb, 768, saturation, hue);
-
-       /*
-        * Then convert the RGB data to the appropriate colorspace and
-       * put it in the image...
-       */
-
-       switch (img->colorspace)
-       {
-         default :
-             break;
-
-         case CF_IMAGE_RGB :
-             cfImageRGBToRGB(rgb, out, 768);
-             break;
-         case CF_IMAGE_CMY :
-             cfImageRGBToCMY(rgb, out, 768);
-             break;
-         case CF_IMAGE_CMYK :
-             cfImageRGBToCMYK(rgb, out, 768);
-             break;
-       }
-
-       if (lut)
-         cfImageLut(out, 768 * bpp, lut);
-
-       if (rotation)
-          _cfImagePutCol(img, 511 - y - pass, 0, 768, out);
-       else
-          _cfImagePutRow(img, 0, y + pass, 768, out);
-      }
-    }
-  }
-
- /*
-  * Free memory and return...
-  */
-
-  free(in);
-  free(out);
-  if (bpp > 1)
-    free(rgb);
-
-  return (0);
-}
-
diff --git a/cupsfilters/image-pix.c b/cupsfilters/image-pix.c
deleted file mode 100644 (file)
index 30adbae..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- *   Alias PIX image routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadPIX() - Read a PIX image file.
- *   read_short()        - Read a 16-bit integer.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-
-
-/*
- * Local functions...
- */
-
-static short   read_short(FILE *fp);
-
-
-/*
- * '_cfImageReadPIX()' - Read a PIX image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadPIX(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  short                width,                  /* Width of image */
-               height,                 /* Height of image */
-               depth;                  /* Depth of image (bits) */
-  int          count,                  /* Repetition count */
-               bpp,                    /* Bytes per pixel */
-               x, y;                   /* Looping vars */
-  cf_ib_t      r, g, b;                /* Red, green/gray, blue values */
-  cf_ib_t      *in,                    /* Input pixels */
-               *out,                   /* Output pixels */
-               *ptr;                   /* Pointer into pixels */
-
-
- /*
-  * Get the image dimensions and setup the image...
-  */
-
-  width  = read_short(fp);
-  height = read_short(fp);
-  read_short(fp);
-  read_short(fp);
-  depth  = read_short(fp);
-
- /*
-  * Check the dimensions of the image.  Since the short values used for the
-  * width and height cannot exceed CF_IMAGE_MAX_WIDTH or
-  * CF_IMAGE_MAX_HEIGHT, we just need to verify they are positive integers.
-  */
-
-  if (width <= 0 || height <= 0 ||
-      (depth != 8 && depth != 24))
-  {
-    DEBUG_printf(("DEBUG: Bad PIX image dimensions %dx%dx%d\n",
-                 width, height, depth));
-    fclose(fp);
-    return (1);
-  }
-
-  if (depth == 8)
-    img->colorspace = secondary;
-  else
-    img->colorspace = (primary == CF_IMAGE_RGB_CMYK) ? CF_IMAGE_RGB : primary;
-
-  img->xsize = width;
-  img->ysize = height;
-
-  cfImageSetMaxTiles(img, 0);
-
-  bpp = cfImageGetDepth(img);
-
-  if ((in = malloc(img->xsize * (depth / 8))) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  if ((out = malloc(img->xsize * bpp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    free(in);
-    return (1);
-  }
-
- /*
-  * Read the image data...
-  */
-
-  if (depth == 8)
-  {
-    for (count = 0, y = 0, g = 0; y < img->ysize; y ++)
-    {
-      if (img->colorspace == CF_IMAGE_WHITE)
-        ptr = out;
-      else
-        ptr = in;
-
-      for (x = img->xsize; x > 0; x --, count --)
-      {
-        if (count == 0)
-       {
-          count = getc(fp);
-         g     = getc(fp);
-       }
-
-        *ptr++ = g;
-      }
-
-      if (img->colorspace != CF_IMAGE_WHITE)
-       switch (img->colorspace)
-       {
-         default :
-             cfImageWhiteToRGB(in, out, img->xsize);
-             break;
-         case CF_IMAGE_BLACK :
-             cfImageWhiteToBlack(in, out, img->xsize);
-             break;
-         case CF_IMAGE_CMY :
-             cfImageWhiteToCMY(in, out, img->xsize);
-             break;
-         case CF_IMAGE_CMYK :
-             cfImageWhiteToCMYK(in, out, img->xsize);
-             break;
-       }
-
-      if (lut)
-       cfImageLut(out, img->xsize * bpp, lut);
-
-      _cfImagePutRow(img, 0, y, img->xsize, out);
-    }
-  }
-  else
-  {
-    for (count = 0, y = 0, r = 0, g = 0, b = 0; y < img->ysize; y ++)
-    {
-      ptr = in;
-
-      for (x = img->xsize; x > 0; x --, count --)
-      {
-        if (count == 0)
-       {
-          count = getc(fp);
-         b     = getc(fp);
-         g     = getc(fp);
-         r     = getc(fp);
-       }
-
-        *ptr++ = r;
-        *ptr++ = g;
-        *ptr++ = b;
-      }
-
-      if (saturation != 100 || hue != 0)
-       cfImageRGBAdjust(in, img->xsize, saturation, hue);
-
-      switch (img->colorspace)
-      {
-       default :
-           break;
-
-       case CF_IMAGE_WHITE :
-           cfImageRGBToWhite(in, out, img->xsize);
-           break;
-       case CF_IMAGE_RGB :
-           cfImageRGBToWhite(in, out, img->xsize);
-           break;
-       case CF_IMAGE_BLACK :
-           cfImageRGBToBlack(in, out, img->xsize);
-           break;
-       case CF_IMAGE_CMY :
-           cfImageRGBToCMY(in, out, img->xsize);
-           break;
-       case CF_IMAGE_CMYK :
-           cfImageRGBToCMYK(in, out, img->xsize);
-           break;
-      }
-
-      if (lut)
-       cfImageLut(out, img->xsize * bpp, lut);
-
-      _cfImagePutRow(img, 0, y, img->xsize, out);
-    }
-  }
-
-  fclose(fp);
-  free(in);
-  free(out);
-
-  return (0);
-}
-
-
-/*
- * 'read_short()' - Read a 16-bit integer.
- */
-
-static short                           /* O - Value from file */
-read_short(FILE *fp)                   /* I - File to read from */
-{
-  int  ch;                             /* Character from file */
-
-
-  ch = getc(fp);
-  return ((ch << 8) | getc(fp));
-}
-
diff --git a/cupsfilters/image-pnm.c b/cupsfilters/image-pnm.c
deleted file mode 100644 (file)
index 035a9e9..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- *   Portable Any Map file routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadPNM() - Read a PNM image file.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-
-
-/*
- * '_cfImageReadPNM()' - Read a PNM image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadPNM(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  int          x, y;                   /* Looping vars */
-  int          bpp;                    /* Bytes per pixel */
-  cf_ib_t      *in,                    /* Input pixels */
-               *inptr,                 /* Current input pixel */
-               *out,                   /* Output pixels */
-               *outptr,                /* Current output pixel */
-               bit;                    /* Bit in input line */
-  char         line[255],              /* Input line */
-               *lineptr;               /* Pointer in line */
-  int          format,                 /* Format of PNM file */
-               val,                    /* Pixel value */
-               maxval;                 /* Maximum pixel value */
-
-
- /*
-  * Read the file header in the format:
-  *
-  *   Pformat
-  *   # comment1
-  *   # comment2
-  *   ...
-  *   # commentN
-  *   width
-  *   height
-  *   max sample
-  */
-
-  if ((lineptr = fgets(line, sizeof(line), fp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Bad PNM header!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  lineptr ++;
-
-  format = atoi(lineptr);
-  while (isdigit(*lineptr & 255))
-    lineptr ++;
-
-  while (lineptr != NULL && img->xsize == 0)
-  {
-    if (*lineptr == '\0' || *lineptr == '#')
-      lineptr = fgets(line, sizeof(line), fp);
-    else if (isdigit(*lineptr & 255))
-    {
-      img->xsize = atoi(lineptr);
-      while (isdigit(*lineptr & 255))
-       lineptr ++;
-    }
-    else
-      lineptr ++;
-  }
-
-  while (lineptr != NULL && img->ysize == 0)
-  {
-    if (*lineptr == '\0' || *lineptr == '#')
-      lineptr = fgets(line, sizeof(line), fp);
-    else if (isdigit(*lineptr & 255))
-    {
-      img->ysize = atoi(lineptr);
-      while (isdigit(*lineptr & 255))
-       lineptr ++;
-    }
-    else
-      lineptr ++;
-  }
-
-  if (format != 1 && format != 4)
-  {
-    maxval = 0;
-
-    while (lineptr != NULL && maxval == 0)
-    {
-      if (*lineptr == '\0' || *lineptr == '#')
-       lineptr = fgets(line, sizeof(line), fp);
-      else if (isdigit(*lineptr & 255))
-      {
-       maxval = atoi(lineptr);
-       while (isdigit(*lineptr & 255))
-         lineptr ++;
-      }
-      else
-       lineptr ++;
-    }
-  }
-  else
-    maxval = 1;
-
-  if (img->xsize == 0 || img->xsize > CF_IMAGE_MAX_WIDTH ||
-      img->ysize == 0 || img->ysize > CF_IMAGE_MAX_HEIGHT)
-  {
-    DEBUG_printf(("DEBUG: Bad PNM dimensions %dx%d!\n",
-                 img->xsize, img->ysize));
-    fclose(fp);
-    return (1);
-  }
-
-  if (maxval == 0)
-  {
-    DEBUG_printf(("DEBUG: Bad PNM max value %d!\n", maxval));
-    fclose(fp);
-    return (1);
-  }
-
-  if (format == 1 || format == 2 || format == 4 || format == 5)
-    img->colorspace = secondary;
-  else
-    img->colorspace = (primary == CF_IMAGE_RGB_CMYK) ? CF_IMAGE_RGB : primary;
-
-  cfImageSetMaxTiles(img, 0);
-
-  bpp = cfImageGetDepth(img);
-
-  if ((in = malloc(img->xsize * 3)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  if ((out = malloc(img->xsize * bpp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    free(in);
-    return (1);
-  }
-
- /*
-  * Read the image file...
-  */
-
-  for (y = 0; y < img->ysize; y ++)
-  {
-    switch (format)
-    {
-      case 1 :
-          for (x = img->xsize, inptr = in; x > 0; x --, inptr ++)
-            if (fscanf(fp, "%d", &val) == 1)
-              *inptr = val ? 0 : 255;
-          break;
-
-      case 2 :
-          for (x = img->xsize, inptr = in; x > 0; x --, inptr ++)
-            if (fscanf(fp, "%d", &val) == 1)
-              *inptr = 255 * val / maxval;
-          break;
-
-      case 3 :
-          for (x = img->xsize, inptr = in; x > 0; x --, inptr += 3)
-          {
-            if (fscanf(fp, "%d", &val) == 1)
-              inptr[0] = 255 * val / maxval;
-            if (fscanf(fp, "%d", &val) == 1)
-              inptr[1] = 255 * val / maxval;
-            if (fscanf(fp, "%d", &val) == 1)
-              inptr[2] = 255 * val / maxval;
-          }
-          break;
-
-      case 4 :
-          if (fread(out, (img->xsize + 7) / 8, 1, fp) == 0 && ferror(fp))
-           DEBUG_printf(("Error reading file!"));
-          for (x = img->xsize, inptr = in, outptr = out, bit = 128;
-               x > 0;
-               x --, inptr ++)
-          {
-            if (*outptr & bit)
-              *inptr = 0;
-            else
-              *inptr = 255;
-
-            if (bit > 1)
-              bit >>= 1;
-            else
-            {
-              bit = 128;
-              outptr ++;
-            }
-          }
-          break;
-
-      case 5 :
-          if (fread(in, img->xsize, 1, fp) == 0 && ferror(fp))
-           DEBUG_printf(("Error reading file!"));
-          break;
-
-      case 6 :
-          if (fread(in, img->xsize, 3, fp) == 0 && ferror(fp))
-           DEBUG_printf(("Error reading file!"));
-          break;
-    }
-
-    switch (format)
-    {
-      case 1 :
-      case 2 :
-      case 4 :
-      case 5 :
-          if (img->colorspace == CF_IMAGE_WHITE)
-         {
-           if (lut)
-             cfImageLut(in, img->xsize, lut);
-
-            _cfImagePutRow(img, 0, y, img->xsize, in);
-         }
-         else
-         {
-           switch (img->colorspace)
-           {
-              default :
-                 break;
-
-             case CF_IMAGE_RGB :
-                 cfImageWhiteToRGB(in, out, img->xsize);
-                 break;
-             case CF_IMAGE_BLACK :
-                 cfImageWhiteToBlack(in, out, img->xsize);
-                 break;
-             case CF_IMAGE_CMY :
-                 cfImageWhiteToCMY(in, out, img->xsize);
-                 break;
-             case CF_IMAGE_CMYK :
-                 cfImageWhiteToCMYK(in, out, img->xsize);
-                 break;
-           }
-
-           if (lut)
-             cfImageLut(out, img->xsize * bpp, lut);
-
-            _cfImagePutRow(img, 0, y, img->xsize, out);
-         }
-         break;
-
-      default :
-         if ((saturation != 100 || hue != 0) && bpp > 1)
-           cfImageRGBAdjust(in, img->xsize, saturation, hue);
-
-         switch (img->colorspace)
-         {
-            default :
-               break;
-
-           case CF_IMAGE_WHITE :
-               cfImageRGBToWhite(in, out, img->xsize);
-               break;
-           case CF_IMAGE_RGB :
-               cfImageRGBToRGB(in, out, img->xsize);
-               break;
-           case CF_IMAGE_BLACK :
-               cfImageRGBToBlack(in, out, img->xsize);
-               break;
-           case CF_IMAGE_CMY :
-               cfImageRGBToCMY(in, out, img->xsize);
-               break;
-           case CF_IMAGE_CMYK :
-               cfImageRGBToCMYK(in, out, img->xsize);
-               break;
-         }
-
-         if (lut)
-           cfImageLut(out, img->xsize * bpp, lut);
-
-          _cfImagePutRow(img, 0, y, img->xsize, out);
-         break;
-    }
-  }
-
-  free(in);
-  free(out);
-
-  fclose(fp);
-
-  return (0);
-}
-
index 0f6feaa315f9bd55e0200ba0a877891b15efcbf5..ce99afb60015ac1132257c833929ce802366e877 100644 (file)
@@ -150,56 +150,16 @@ extern int                _cfImagePutCol(cf_image_t *img, int x, int y,
                                       int height, const cf_ib_t *pixels);
 extern int             _cfImagePutRow(cf_image_t *img, int x, int y,
                                       int width, const cf_ib_t *pixels);
-extern int             _cfImageReadBMP(cf_image_t *img, FILE *fp,
-                                       cf_icspace_t primary,
-                                       cf_icspace_t secondary,
-                                       int saturation, int hue,
-                                       const cf_ib_t *lut);
-extern int             _cfImageReadFPX(cf_image_t *img, FILE *fp,
-                                       cf_icspace_t primary,
-                                       cf_icspace_t secondary,
-                                       int saturation, int hue,
-                                       const cf_ib_t *lut);
-extern int             _cfImageReadGIF(cf_image_t *img, FILE *fp,
-                                       cf_icspace_t primary,
-                                       cf_icspace_t secondary,
-                                       int saturation, int hue,
-                                       const cf_ib_t *lut);
 extern int             _cfImageReadJPEG(cf_image_t *img, FILE *fp,
                                         cf_icspace_t primary,
                                         cf_icspace_t secondary,
                                         int saturation, int hue,
                                         const cf_ib_t *lut);
-extern int             _cfImageReadPIX(cf_image_t *img, FILE *fp,
-                                       cf_icspace_t primary,
-                                       cf_icspace_t secondary,
-                                       int saturation, int hue,
-                                       const cf_ib_t *lut);
 extern int             _cfImageReadPNG(cf_image_t *img, FILE *fp,
                                        cf_icspace_t primary,
                                        cf_icspace_t secondary,
                                        int saturation, int hue,
                                        const cf_ib_t *lut);
-extern int             _cfImageReadPNM(cf_image_t *img, FILE *fp,
-                                       cf_icspace_t primary,
-                                       cf_icspace_t secondary,
-                                       int saturation, int hue,
-                                       const cf_ib_t *lut);
-extern int             _cfImageReadPhotoCD(cf_image_t *img, FILE *fp,
-                                           cf_icspace_t primary,
-                                           cf_icspace_t secondary,
-                                           int saturation, int hue,
-                                           const cf_ib_t *lut);
-extern int             _cfImageReadSGI(cf_image_t *img, FILE *fp,
-                                       cf_icspace_t primary,
-                                       cf_icspace_t secondary,
-                                       int saturation, int hue,
-                                       const cf_ib_t *lut);
-extern int             _cfImageReadSunRaster(cf_image_t *img, FILE *fp,
-                                             cf_icspace_t primary,
-                                             cf_icspace_t secondary,
-                                             int saturation, int hue,
-                                             const cf_ib_t *lut);
 extern int             _cfImageReadTIFF(cf_image_t *img, FILE *fp,
                                         cf_icspace_t primary,
                                         cf_icspace_t secondary,
diff --git a/cupsfilters/image-sgi.c b/cupsfilters/image-sgi.c
deleted file mode 100644 (file)
index baf9829..0000000
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- *   SGI image file routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadSGI() - Read a SGI image file.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-/*
- * Constants...
- */
-
-#  define CF_SGI_MAGIC         474     /* Magic number in image file */
-
-#  define CF_SGI_COMP_NONE     0       /* No compression */
-#  define CF_SGI_COMP_RLE      1       /* Run-length encoding */
-#  define CF_SGI_COMP_ARLE     2       /* Agressive run-length encoding */
-
-
-/*
- * Image structure...
- */
-
-typedef struct
-{
-  FILE                 *file;          /* Image file */
-  int                  bpp,            /* Bytes per pixel/channel */
-                       comp;           /* Compression */
-  unsigned short       xsize,          /* Width in pixels */
-                       ysize,          /* Height in pixels */
-                       zsize;          /* Number of channels */
-  long                 firstrow,       /* File offset for first row */
-                       nextrow,        /* File offset for next row */
-                       **table,        /* Offset table for compression */
-                       **length;       /* Length table for compression */
-  unsigned short       *arle_row;      /* Advanced RLE compression buffer */
-  long                 arle_offset,    /* Advanced RLE buffer offset */
-                       arle_length;    /* Advanced RLE buffer length */
-} cf_sgi_t;
-
-
-/*
- * Local functions...
- */
-
-static int     sgi_close(cf_sgi_t *sgip);
-static int     sgi_get_row(cf_sgi_t *sgip, unsigned short *row, int y, int z);
-static cf_sgi_t        *sgi_open_file(FILE *file, int comp, int bpp,
-                              int xsize, int ysize, int zsize);
-static int     get_long(FILE *);
-static int     get_short(FILE *);
-static int     read_rle8(FILE *, unsigned short *, int);
-static int     read_rle16(FILE *, unsigned short *, int);
-
-
-/*
- * '_cfImageReadSGI()' - Read a SGI image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadSGI(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  int          i, y;                   /* Looping vars */
-  int          bpp;                    /* Bytes per pixel */
-  cf_sgi_t             *sgip;                  /* SGI image file */
-  cf_ib_t      *in,                    /* Input pixels */
-               *inptr,                 /* Current input pixel */
-               *out;                   /* Output pixels */
-  unsigned short *rows[4],             /* Row pointers for image data */
-               *red,
-               *green,
-               *blue,
-               *gray,
-               *alpha;
-
-
- /*
-  * Setup the SGI file...
-  */
-
-  sgip = sgi_open_file(fp, 0, 0, 0, 0, 0);
-
- /*
-  * Get the image dimensions and load the output image...
-  */
-
- /*
-  * Check the image dimensions; since xsize and ysize are unsigned shorts,
-  * just check if they are 0 since they can't exceed CF_IMAGE_MAX_WIDTH or
-  * CF_IMAGE_MAX_HEIGHT...
-  */
-
-  if (sgip->xsize == 0 || sgip->ysize == 0 ||
-      sgip->zsize == 0 || sgip->zsize > 4)
-  {
-    DEBUG_printf(("DEBUG: Bad SGI image dimensions %ux%ux%u!\n",
-                 sgip->xsize, sgip->ysize, sgip->zsize));
-    sgi_close(sgip);
-    return (1);
-  }
-
-  if (sgip->zsize < 3)
-    img->colorspace = secondary;
-  else
-    img->colorspace = (primary == CF_IMAGE_RGB_CMYK) ? CF_IMAGE_RGB : primary;
-
-  img->xsize = sgip->xsize;
-  img->ysize = sgip->ysize;
-
-  cfImageSetMaxTiles(img, 0);
-
-  bpp = cfImageGetDepth(img);
-
-  if ((in = malloc(img->xsize * sgip->zsize)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    sgi_close(sgip);
-    return (1);
-  }
-
-  if ((out = malloc(img->xsize * bpp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    sgi_close(sgip);
-    free(in);
-    return (1);
-  }
-
-  if ((rows[0] = calloc(img->xsize * sgip->zsize,
-                        sizeof(unsigned short))) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    sgi_close(sgip);
-    free(in);
-    free(out);
-    return (1);
-  }
-
-  for (i = 1; i < sgip->zsize; i ++)
-    rows[i] = rows[0] + i * img->xsize;
-
- /*
-  * Read the SGI image file...
-  */
-
-  for (y = 0; y < img->ysize; y ++)
-  {
-    for (i = 0; i < sgip->zsize; i ++)
-      sgi_get_row(sgip, rows[i], img->ysize - 1 - y, i);
-
-    switch (sgip->zsize)
-    {
-      case 1 :
-          if (sgip->bpp == 1)
-           for (i = img->xsize - 1, gray = rows[0], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = *gray++;
-            }
-          else
-           for (i = img->xsize - 1, gray = rows[0], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = (*gray++) / 256 + 128;
-            }
-          break;
-      case 2 :
-          if (sgip->bpp == 1)
-           for (i = img->xsize - 1, gray = rows[0], alpha = rows[1], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = (*gray++) * (*alpha++) / 255;
-            }
-          else
-           for (i = img->xsize - 1, gray = rows[0], alpha = rows[1], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = ((*gray++) / 256 + 128) * (*alpha++) / 32767;
-            }
-          break;
-      case 3 :
-          if (sgip->bpp == 1)
-           for (i = img->xsize - 1, red = rows[0], green = rows[1],
-                    blue = rows[2], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = *red++;
-              *inptr++ = *green++;
-              *inptr++ = *blue++;
-            }
-          else
-           for (i = img->xsize - 1, red = rows[0], green = rows[1],
-                    blue = rows[2], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = (*red++) / 256 + 128;
-              *inptr++ = (*green++) / 256 + 128;
-              *inptr++ = (*blue++) / 256 + 128;
-            }
-          break;
-      case 4 :
-          if (sgip->bpp == 1)
-           for (i = img->xsize - 1, red = rows[0], green = rows[1],
-                    blue = rows[2], alpha = rows[3], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = (*red++) * (*alpha) / 255;
-              *inptr++ = (*green++) * (*alpha) / 255;
-              *inptr++ = (*blue++) * (*alpha++) / 255;
-            }
-          else
-           for (i = img->xsize - 1, red = rows[0], green = rows[1],
-                    blue = rows[2], alpha = rows[3], inptr = in;
-                i >= 0;
-                i --)
-            {
-              *inptr++ = ((*red++) / 256 + 128) * (*alpha) / 32767;
-              *inptr++ = ((*green++) / 256 + 128) * (*alpha) / 32767;
-              *inptr++ = ((*blue++) / 256 + 128) * (*alpha++) / 32767;
-            }
-          break;
-    }
-
-    if (sgip->zsize < 3)
-    {
-      if (img->colorspace == CF_IMAGE_WHITE)
-      {
-        if (lut)
-         cfImageLut(in, img->xsize, lut);
-
-        _cfImagePutRow(img, 0, y, img->xsize, in);
-      }
-      else
-      {
-       switch (img->colorspace)
-       {
-         default :
-             break;
-
-         case CF_IMAGE_RGB :
-         case CF_IMAGE_RGB_CMYK :
-             cfImageWhiteToRGB(in, out, img->xsize);
-             break;
-         case CF_IMAGE_BLACK :
-             cfImageWhiteToBlack(in, out, img->xsize);
-             break;
-         case CF_IMAGE_CMY :
-             cfImageWhiteToCMY(in, out, img->xsize);
-             break;
-         case CF_IMAGE_CMYK :
-             cfImageWhiteToCMYK(in, out, img->xsize);
-             break;
-       }
-
-        if (lut)
-         cfImageLut(out, img->xsize * bpp, lut);
-
-        _cfImagePutRow(img, 0, y, img->xsize, out);
-      }
-    }
-    else
-    {
-      if ((saturation != 100 || hue != 0) && bpp > 1)
-       cfImageRGBAdjust(in, img->xsize, saturation, hue);
-
-      switch (img->colorspace)
-      {
-       default :
-           break;
-
-       case CF_IMAGE_WHITE :
-           cfImageRGBToWhite(in, out, img->xsize);
-           break;
-       case CF_IMAGE_RGB :
-           cfImageRGBToRGB(in, out, img->xsize);
-           break;
-       case CF_IMAGE_BLACK :
-           cfImageRGBToBlack(in, out, img->xsize);
-           break;
-       case CF_IMAGE_CMY :
-           cfImageRGBToCMY(in, out, img->xsize);
-           break;
-       case CF_IMAGE_CMYK :
-           cfImageRGBToCMYK(in, out, img->xsize);
-           break;
-      }
-
-      if (lut)
-       cfImageLut(out, img->xsize * bpp, lut);
-
-      _cfImagePutRow(img, 0, y, img->xsize, out);
-    }
-  }
-
-  free(in);
-  free(out);
-  free(rows[0]);
-
-  sgi_close(sgip);
-
-  return (0);
-}
-
-
-/*
- * 'sgi_close()' - Close an SGI image file.
- */
-
-static int                             /* O - 0 on success, -1 on error */
-sgi_close(cf_sgi_t *sgip)              /* I - SGI image */
-{
-  int  i;                              /* Return status */
-
-
-  if (sgip == NULL)
-    return (-1);
-
-  if (sgip->table != NULL)
-  {
-    free(sgip->table[0]);
-    free(sgip->table);
-  }
-
-  if (sgip->length != NULL)
-  {
-    free(sgip->length[0]);
-    free(sgip->length);
-  }
-
-  if (sgip->comp == CF_SGI_COMP_ARLE)
-    free(sgip->arle_row);
-
-  i = fclose(sgip->file);
-  free(sgip);
-
-  return (i);
-}
-
-
-/*
- * 'sgi_get_row()' - Get a row of image data from a file.
- */
-
-static int                             /* O - 0 on success, -1 on error */
-sgi_get_row(cf_sgi_t          *sgip,   /* I - SGI image */
-          unsigned short *row,         /* O - Row to read */
-          int            y,            /* I - Line to read */
-          int            z)            /* I - Channel to read */
-{
-  int  x;                              /* X coordinate */
-  long offset;                         /* File offset */
-
-
-  if (sgip == NULL ||
-      row == NULL ||
-      y < 0 || y >= sgip->ysize ||
-      z < 0 || z >= sgip->zsize)
-    return (-1);
-
-  switch (sgip->comp)
-  {
-    case CF_SGI_COMP_NONE :
-       /*
-        * Seek to the image row - optimize buffering by only seeking if
-        * necessary...
-        */
-
-        offset = 512 + (y + z * sgip->ysize) * sgip->xsize * sgip->bpp;
-        if (offset != ftell(sgip->file))
-          fseek(sgip->file, offset, SEEK_SET);
-
-        if (sgip->bpp == 1)
-        {
-          for (x = sgip->xsize; x > 0; x --, row ++)
-            *row = getc(sgip->file);
-        }
-        else
-        {
-          for (x = sgip->xsize; x > 0; x --, row ++)
-            *row = get_short(sgip->file);
-        }
-        break;
-
-    case CF_SGI_COMP_RLE :
-        offset = sgip->table[z][y];
-        if (offset != ftell(sgip->file))
-          fseek(sgip->file, offset, SEEK_SET);
-
-        if (sgip->bpp == 1)
-          return (read_rle8(sgip->file, row, sgip->xsize));
-        else
-          return (read_rle16(sgip->file, row, sgip->xsize));
-  }
-
-  return (0);
-}
-
-
-/*
- * 'sgi_open_file()' - Open an SGI image file for reading or writing.
- */
-
-static cf_sgi_t *                      /* O - New image */
-sgi_open_file(FILE *file,              /* I - File to open */
-              int  comp,               /* I - Type of compression */
-              int  bpp,                        /* I - Bytes per pixel */
-              int  xsize,              /* I - Width of image in pixels */
-              int  ysize,              /* I - Height of image in pixels */
-              int  zsize)              /* I - Number of channels */
-{
-  int  i, j;                           /* Looping var */
-  short        magic;                          /* Magic number */
-  cf_sgi_t     *sgip;                  /* New image pointer */
-
-
-  if ((sgip = calloc(sizeof(cf_sgi_t), 1)) == NULL)
-    return (NULL);
-
-  sgip->file = file;
-
-  magic = get_short(sgip->file);
-  if (magic != CF_SGI_MAGIC)
-  {
-    free(sgip);
-    return (NULL);
-  }
-
-  sgip->comp  = getc(sgip->file);
-  sgip->bpp   = getc(sgip->file);
-  get_short(sgip->file);               /* Dimensions */
-  sgip->xsize = get_short(sgip->file);
-  sgip->ysize = get_short(sgip->file);
-  sgip->zsize = get_short(sgip->file);
-  get_long(sgip->file);                /* Minimum pixel */
-  get_long(sgip->file);                /* Maximum pixel */
-
-  if (sgip->comp)
-  {
-   /*
-    * This file is compressed; read the scanline tables...
-    */
-
-    fseek(sgip->file, 512, SEEK_SET);
-
-    if ((sgip->table = calloc(sgip->zsize, sizeof(long *))) == NULL)
-    {
-      free(sgip);
-      return (NULL);
-    }
-
-    if ((sgip->table[0] = calloc(sgip->ysize * sgip->zsize,
-                                sizeof(long))) == NULL)
-    {
-      free(sgip->table);
-      free(sgip);
-      return (NULL);
-    }
-
-    for (i = 1; i < sgip->zsize; i ++)
-      sgip->table[i] = sgip->table[0] + i * sgip->ysize;
-
-    for (i = 0; i < sgip->zsize; i ++)
-      for (j = 0; j < sgip->ysize; j ++)
-       sgip->table[i][j] = get_long(sgip->file);
-  }
-
-  return (sgip);
-}
-
-
-/*
- * 'get_long()' - Get a 32-bit big-endian integer.
- */
-
-static int                             /* O - Long value */
-get_long(FILE *fp)                     /* I - File to read from */
-{
-  unsigned char        b[4];                   /* Bytes from file */
-
-
-  if (fread(b, 4, 1, fp) == 0 && ferror(fp))
-    DEBUG_printf(("Error reading file!"));
-  return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
-}
-
-
-/*
- * 'get_short()' - Get a 16-bit big-endian integer.
- */
-
-static int                             /* O - Short value */
-get_short(FILE *fp)                    /* I - File to read from */
-{
-  unsigned char        b[2];                   /* Bytes from file */
-
-
-  if (fread(b, 2, 1, fp) == 0 && ferror(fp))
-    DEBUG_printf(("Error reading file!"));
-  return ((b[0] << 8) | b[1]);
-}
-
-
-/*
- * 'read_rle8()' - Read 8-bit RLE data.
- */
-
-static int                             /* O - Value on success, -1 on error */
-read_rle8(FILE           *fp,          /* I - File to read from */
-          unsigned short *row,         /* O - Data */
-          int            xsize)                /* I - Width of data in pixels */
-{
-  int  i,                              /* Looping var */
-       ch,                             /* Current character */
-       count,                          /* RLE count */
-       length;                         /* Number of bytes read... */
-
-
-  length = 0;
-
-  while (xsize > 0)
-  {
-    if ((ch = getc(fp)) == EOF)
-      return (-1);
-    length ++;
-
-    count = ch & 127;
-    if (count == 0)
-      break;
-
-    if (ch & 128)
-    {
-      for (i = 0; i < count; i ++, row ++, xsize --, length ++)
-        if (xsize > 0)
-         *row = getc(fp);
-    }
-    else
-    {
-      ch = getc(fp);
-      length ++;
-      for (i = 0; i < count && xsize > 0; i ++, row ++, xsize --)
-        *row = ch;
-    }
-  }
-
-  return (xsize > 0 ? -1 : length);
-}
-
-
-/*
- * 'read_rle16()' - Read 16-bit RLE data.
- */
-
-static int                             /* O - Value on success, -1 on error */
-read_rle16(FILE           *fp,         /* I - File to read from */
-           unsigned short *row,                /* O - Data */
-           int            xsize)       /* I - Width of data in pixels */
-{
-  int  i,                              /* Looping var */
-       ch,                             /* Current character */
-       count,                          /* RLE count */
-       length;                         /* Number of bytes read... */
-
-
-  length = 0;
-
-  while (xsize > 0)
-  {
-    if ((ch = get_short(fp)) == EOF)
-      return (-1);
-    length ++;
-
-    count = ch & 127;
-    if (count == 0)
-      break;
-
-    if (ch & 128)
-    {
-      for (i = 0; i < count; i ++, row ++, xsize --, length ++)
-        if (xsize > 0)
-         *row = get_short(fp);
-    }
-    else
-    {
-      ch = get_short(fp);
-      length ++;
-      for (i = 0; i < count && xsize > 0; i ++, row ++, xsize --)
-       *row = ch;
-    }
-  }
-
-  return (xsize > 0 ? -1 : length * 2);
-}
diff --git a/cupsfilters/image-sun.c b/cupsfilters/image-sun.c
deleted file mode 100644 (file)
index e6b045c..0000000
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- *   Sun Raster image file routines for CUPS.
- *
- *   Copyright 2007-2011 by Apple Inc.
- *   Copyright 1993-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "COPYING"
- *   which should have been included with this file.
- *
- * Contents:
- *
- *   _cfImageReadSunRaster() - Read a SunRaster image file.
- *   read_unsigned()      - Read a 32-bit unsigned integer.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "image-private.h"
-
-
-#define        RAS_MAGIC       0x59a66a95
-
-       /* Sun supported ras_type's */
-#define RT_OLD         0               /* Raw pixrect image in 68000 byte order */
-#define RT_STANDARD    1               /* Raw pixrect image in 68000 byte order */
-#define RT_BYTE_ENCODED        2               /* Run-length compression of bytes */
-#define RT_FORMAT_RGB  3               /* XRGB or RGB instead of XBGR or BGR */
-#define RT_EXPERIMENTAL        0xffff          /* Reserved for testing */
-
-       /* Sun registered ras_maptype's */
-#define RMT_RAW                2
-       /* Sun supported ras_maptype's */
-#define RMT_NONE       0               /* ras_maplength is expected to be 0 */
-#define RMT_EQUAL_RGB  1               /* red[ras_maplength/3],green[],blue[] */
-
-#define RAS_RLE 0x80
-
-/*
- * NOTES:
- *     Each line of the image is rounded out to a multiple of 16 bits.
- *   This corresponds to the rounding convention used by the memory pixrect
- *   package (/usr/include/pixrect/memvar.h) of the SunWindows system.
- *     The ras_encoding field (always set to 0 by Sun's supported software)
- *   was renamed to ras_length in release 2.0.  As a result, rasterfiles
- *   of type 0 generated by the old software claim to have 0 length; for
- *   compatibility, code reading rasterfiles must be prepared to compute the
- *   true length from the width, height, and depth fields.
- */
-
-/*
- * Local functions...
- */
-
-static unsigned        read_unsigned(FILE *fp);
-
-
-/*
- * '_cfImageReadSunRaster()' - Read a SunRaster image file.
- */
-
-int                                    /* O - Read status */
-_cfImageReadSunRaster(
-    cf_image_t    *img,                /* IO - Image */
-    FILE            *fp,               /* I - Image file */
-    cf_icspace_t  primary,             /* I - Primary choice for colorspace */
-    cf_icspace_t  secondary,           /* I - Secondary choice for colorspace */
-    int             saturation,                /* I - Color saturation (%) */
-    int             hue,               /* I - Color hue (degrees) */
-    const cf_ib_t *lut)                /* I - Lookup table for gamma/brightness */
-{
-  int          i, x, y,
-               bpp,                    /* Bytes per pixel */
-               scanwidth,
-               run_count,
-               run_value;
-  cf_ib_t      *in,
-               *out,
-               *scanline,
-               *scanptr,
-               *p,
-               bit;
-  unsigned     ras_depth,              /* depth (1, 8, or 24 bits) of pixel */
-               ras_type,               /* type of file; see RT_* below */
-               ras_maplength;          /* length (bytes) of following map */
-  unsigned char        cmap[3][256];           /* colormap */
-
-
- /*
-  * Read the header; we already know that this is a raster file (cfImageOpen
-  * checks this) so we don't need to check the magic number again.
-  */
-
-  DEBUG_puts("DEBUG: Reading Sun Raster image...\n");
-
-  read_unsigned(fp); /* Skip magic */
-  img->xsize    = read_unsigned(fp);
-  img->ysize    = read_unsigned(fp);
-  ras_depth     = read_unsigned(fp);
-  /* ras_length */read_unsigned(fp);
-  ras_type      = read_unsigned(fp);
-  /* ras_maptype*/read_unsigned(fp);
-  ras_maplength = read_unsigned(fp);
-
-  DEBUG_printf(("DEBUG: ras_width=%d, ras_height=%d, ras_depth=%d, ras_type=%d, ras_maplength=%d\n",
-               img->xsize, img->ysize, ras_depth, ras_type, ras_maplength));
-
-  if (ras_maplength > 768 ||
-      img->xsize == 0 || img->xsize > CF_IMAGE_MAX_WIDTH ||
-      img->ysize == 0 || img->ysize > CF_IMAGE_MAX_HEIGHT ||
-      ras_depth == 0 || ras_depth > 32)
-  {
-    DEBUG_puts("DEBUG: Raster image cannot be loaded!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  if (ras_maplength > 0)
-  {
-    memset(cmap[0], 255, sizeof(cmap[0]));
-    memset(cmap[1], 0, sizeof(cmap[1]));
-    memset(cmap[2], 0, sizeof(cmap[2]));
-
-    if (fread(cmap[0], 1, ras_maplength / 3, fp) == 0 && ferror(fp))
-      DEBUG_printf(("Error reading file!"));
-    if (fread(cmap[1], 1, ras_maplength / 3, fp) == 0 && ferror(fp))
-      DEBUG_printf(("Error reading file!"));
-    if (fread(cmap[2], 1, ras_maplength / 3, fp) == 0 && ferror(fp))
-      DEBUG_printf(("Error reading file!"));
-  }
-
- /*
-  * Compute the width of each line and allocate memory as needed...
-  */
-
-  scanwidth = (img->xsize * ras_depth + 7) / 8;
-  if (scanwidth & 1)
-    scanwidth ++;
-
-  if (ras_depth < 24 && ras_maplength == 0)
-  {
-    img->colorspace = secondary;
-    in = malloc(img->xsize + 1);
-  }
-  else
-  {
-    img->colorspace = (primary == CF_IMAGE_RGB_CMYK) ? CF_IMAGE_RGB : primary;
-    in = malloc(img->xsize * 3 + 1);
-  }
-
-  if (!in)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    return (1);
-  }
-
-  bpp = cfImageGetDepth(img);
-
-  if ((out = malloc(img->xsize * bpp)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    free(in);
-    return (1);
-  }
-
-  if ((scanline = malloc(scanwidth)) == NULL)
-  {
-    DEBUG_puts("DEBUG: Unable to allocate memory!\n");
-    fclose(fp);
-    free(in);
-    free(out);
-    return (1);
-  }
-
-  run_count = 0;
-  run_value = 0;
-
-  DEBUG_printf(("DEBUG: bpp=%d, scanwidth=%d\n", bpp, scanwidth));
-
-  for (y = 0; y < img->ysize; y ++)
-  {
-    if ((ras_depth != 8 && ras_depth != 24) || ras_maplength > 0)
-      p = scanline;
-    else
-      p = in;
-
-    if (ras_type != RT_BYTE_ENCODED)
-    {
-      if (fread(p, scanwidth, 1, fp) == 0 && ferror(fp))
-       DEBUG_printf(("Error reading file!"));
-    }
-    else
-    {
-      for (i = scanwidth; i > 0; i --, p ++)
-      {
-        if (run_count > 0)
-        {
-          *p = run_value;
-          run_count --;
-        }
-        else
-        {
-          run_value = getc(fp);
-
-          if (run_value == RAS_RLE)
-          {
-            run_count = getc(fp);
-            if (run_count == 0)
-              *p = RAS_RLE;
-            else
-              run_value = *p = getc(fp);
-          }
-          else
-            *p = run_value;
-        }
-      }
-    }
-
-    if (ras_depth == 1 && ras_maplength == 0)
-    {
-     /*
-      * 1-bit B&W image...
-      */
-
-      for (x = img->xsize, bit = 128, scanptr = scanline, p = in;
-           x > 0;
-           x --, p ++)
-      {
-       if (*scanptr & bit)
-          *p = 255;
-        else
-          *p = 0;
-
-       if (bit > 1)
-          bit >>= 1;
-       else
-       {
-          bit = 128;
-          scanptr ++;
-       }
-      }
-    }
-    else if (ras_depth == 1)
-    {
-     /*
-      * 1-bit colormapped image...
-      */
-
-      for (x = img->xsize, bit = 128, scanptr = scanline, p = in;
-           x > 0;
-           x --)
-      {
-       if (*scanptr & bit)
-       {
-          *p++ = cmap[0][1];
-          *p++ = cmap[1][1];
-          *p++ = cmap[2][1];
-       }
-        else
-       {
-          *p++ = cmap[0][0];
-          *p++ = cmap[1][0];
-          *p++ = cmap[2][0];
-       }
-
-       if (bit > 1)
-          bit >>= 1;
-       else
-       {
-          bit = 128;
-          scanptr ++;
-       }
-      }
-    }
-    else if (ras_depth == 8 && ras_maplength > 0)
-    {
-     /*
-      * 8-bit colormapped image.
-      */
-
-      for (x = img->xsize, scanptr = scanline, p = in;
-           x > 0;
-           x --)
-      {
-        *p++ = cmap[0][*scanptr];
-        *p++ = cmap[1][*scanptr];
-        *p++ = cmap[2][*scanptr++];
-      }
-    }
-    else if (ras_depth == 24 && ras_type != RT_FORMAT_RGB)
-    {
-     /*
-      * Convert BGR to RGB...
-      */
-
-      for (x = img->xsize, scanptr = scanline, p = in;
-           x > 0;
-           x --, scanptr += 3)
-      {
-        *p++ = scanptr[2];
-        *p++ = scanptr[1];
-        *p++ = scanptr[0];
-      }
-    }
-
-    if (ras_depth <= 8 && ras_maplength == 0)
-    {
-      if (img->colorspace == CF_IMAGE_WHITE)
-      {
-        if (lut)
-         cfImageLut(in, img->xsize, lut);
-
-        _cfImagePutRow(img, 0, y, img->xsize, in);
-      }
-      else
-      {
-       switch (img->colorspace)
-       {
-         default :
-             break;
-
-         case CF_IMAGE_RGB :
-             cfImageWhiteToRGB(in, out, img->xsize);
-             break;
-         case CF_IMAGE_BLACK :
-             cfImageWhiteToBlack(in, out, img->xsize);
-             break;
-         case CF_IMAGE_CMY :
-             cfImageWhiteToCMY(in, out, img->xsize);
-             break;
-         case CF_IMAGE_CMYK :
-             cfImageWhiteToCMYK(in, out, img->xsize);
-             break;
-       }
-
-        if (lut)
-         cfImageLut(out, img->xsize * bpp, lut);
-
-        _cfImagePutRow(img, 0, y, img->xsize, out);
-      }
-    }
-    else
-    {
-      if ((saturation != 100 || hue != 0) && bpp > 1)
-       cfImageRGBAdjust(in, img->xsize, saturation, hue);
-
-      switch (img->colorspace)
-      {
-       default :
-           break;
-
-       case CF_IMAGE_WHITE :
-           cfImageRGBToWhite(in, out, img->xsize);
-           break;
-       case CF_IMAGE_BLACK :
-           cfImageRGBToBlack(in, out, img->xsize);
-           break;
-       case CF_IMAGE_CMY :
-           cfImageRGBToCMY(in, out, img->xsize);
-           break;
-       case CF_IMAGE_CMYK :
-           cfImageRGBToCMYK(in, out, img->xsize);
-           break;
-      }
-
-      if (lut)
-       cfImageLut(out, img->xsize * bpp, lut);
-
-      _cfImagePutRow(img, 0, y, img->xsize, out);
-    }
-  }
-
-  free(scanline);
-  free(in);
-  free(out);
-
-  fclose(fp);
-
-  return (0);
-}
-
-
-/*
- * 'read_unsigned()' - Read a 32-bit unsigned integer.
- */
-
-static unsigned                                /* O - Integer from file */
-read_unsigned(FILE *fp)                        /* I - File to read from */
-{
-  unsigned     v;                      /* Integer from file */
-
-
-  v = getc(fp);
-  v = (v << 8) | getc(fp);
-  v = (v << 8) | getc(fp);
-  v = (v << 8) | getc(fp);
-
-  return (v);
-}
-
index 86cabba2a133ea2d80d691088dd5ff27d927d50d..836309d1d135c89398f17706bc35952fdd2dfe07 100644 (file)
@@ -380,47 +380,26 @@ cfImageOpenFP(
   img->xppi      = 200;
   img->yppi      = 200;
 
-  if (!memcmp(header, "GIF87a", 6) || !memcmp(header, "GIF89a", 6))
-    status = _cfImageReadGIF(img, fp, primary, secondary, saturation, hue,
-                               lut);
-  else if (!memcmp(header, "BM", 2))
-    status = _cfImageReadBMP(img, fp, primary, secondary, saturation, hue,
-                               lut);
-  else if (header[0] == 0x01 && header[1] == 0xda)
-    status = _cfImageReadSGI(img, fp, primary, secondary, saturation, hue,
-                               lut);
-  else if (header[0] == 0x59 && header[1] == 0xa6 &&
-           header[2] == 0x6a && header[3] == 0x95)
-    status = _cfImageReadSunRaster(img, fp, primary, secondary, saturation,
-                                     hue, lut);
-  else if (header[0] == 'P' && header[1] >= '1' && header[1] <= '6')
-    status = _cfImageReadPNM(img, fp, primary, secondary, saturation, hue,
-                               lut);
-  else if (!memcmp(header2, "PCD_IPI", 7))
-    status = _cfImageReadPhotoCD(img, fp, primary, secondary, saturation,
-                                   hue, lut);
-  else if (!memcmp(header + 8, "\000\010", 2) ||
-           !memcmp(header + 8, "\000\030", 2))
-    status = _cfImageReadPIX(img, fp, primary, secondary, saturation, hue,
-                               lut);
 #if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
-  else if (!memcmp(header, "\211PNG", 4))
+  if (!memcmp(header, "\211PNG", 4))
     status = _cfImageReadPNG(img, fp, primary, secondary, saturation, hue,
                                lut);
+  else
 #endif /* HAVE_LIBPNG && HAVE_LIBZ */
 #ifdef HAVE_LIBJPEG
-  else if (!memcmp(header, "\377\330\377", 3) &&       /* Start-of-Image */
+  if (!memcmp(header, "\377\330\377", 3) &&    /* Start-of-Image */
           header[3] >= 0xe0 && header[3] <= 0xef)      /* APPn */
     status = _cfImageReadJPEG(img, fp, primary, secondary, saturation, hue,
                                 lut);
+  else
 #endif /* HAVE_LIBJPEG */
 #ifdef HAVE_LIBTIFF
-  else if (!memcmp(header, "MM\000\052", 4) ||
+  if (!memcmp(header, "MM\000\052", 4) ||
            !memcmp(header, "II\052\000", 4))
     status = _cfImageReadTIFF(img, fp, primary, secondary, saturation, hue,
                                 lut);
-#endif /* HAVE_LIBTIFF */
   else
+#endif /* HAVE_LIBTIFF */
   {
     fclose(fp);
     status = -1;
index a020652a6d3fa4f5f50cc8718f6af68e70e141b8..0b7947a220db1c22dcbf777f07171e065f3bd113 100644 (file)
 application/pdf                application/vnd.cups-pdf                66      pdftopdf
 text/plain             application/pdf                         32      texttopdf
 image/pwg-raster       application/pdf                         32      pwgtopdf
-image/gif              application/vnd.cups-pdf                65      imagetopdf
 image/png              application/vnd.cups-pdf                65      imagetopdf
 image/jpeg             application/vnd.cups-pdf                65      imagetopdf
 image/tiff             application/vnd.cups-pdf                65      imagetopdf
-image/x-bitmap         application/vnd.cups-pdf                65      imagetopdf
-image/x-photocd                application/vnd.cups-pdf                65      imagetopdf
-image/x-portable-anymap        application/vnd.cups-pdf                65      imagetopdf
-image/x-portable-bitmap        application/vnd.cups-pdf                65      imagetopdf
-image/x-portable-graymap application/vnd.cups-pdf              65      imagetopdf
-image/x-portable-pixmap        application/vnd.cups-pdf                65      imagetopdf
-image/x-sgi-rgb                application/vnd.cups-pdf                65      imagetopdf
-image/x-xbitmap                application/vnd.cups-pdf                65      imagetopdf
-image/x-xpixmap                application/vnd.cups-pdf                65      imagetopdf
-image/x-xwindowdump    application/vnd.cups-pdf                65      imagetopdf
-image/x-sun-raster     application/vnd.cups-pdf                65      imagetopdf
 application/vnd.cups-pdf-banner        application/pdf                 32      bannertopdf
 image/urf              application/pdf                         0       pwgtopdf
 
@@ -87,20 +75,9 @@ application/vnd.adobe-reader-postscript      application/vnd.cups-postscript 66      pstop
 #
 
 application/PCLm               application/vnd.cups-raster     32      pclmtoraster
-image/gif                      application/vnd.cups-raster     100     imagetoraster
 image/png                      application/vnd.cups-raster     100     imagetoraster
 image/jpeg                     application/vnd.cups-raster     100     imagetoraster
 image/tiff                     application/vnd.cups-raster     100     imagetoraster
-image/x-bitmap                 application/vnd.cups-raster     100     imagetoraster
-image/x-photocd                        application/vnd.cups-raster     100     imagetoraster
-image/x-portable-anymap                application/vnd.cups-raster     100     imagetoraster
-image/x-portable-bitmap                application/vnd.cups-raster     100     imagetoraster
-image/x-portable-graymap       application/vnd.cups-raster     100     imagetoraster
-image/x-portable-pixmap                application/vnd.cups-raster     100     imagetoraster
-image/x-sgi-rgb                        application/vnd.cups-raster     100     imagetoraster
-image/x-xbitmap                        application/vnd.cups-raster     100     imagetoraster
-image/x-xpixmap                        application/vnd.cups-raster     100     imagetoraster
-image/x-sun-raster             application/vnd.cups-raster     100     imagetoraster
 image/pwg-raster               application/vnd.cups-raster     100     pwgtoraster
 image/urf                      application/vnd.cups-raster     100     pwgtoraster
 image/pwg-raster               image/urf                       100     pwgtoraster
index 2e1fde42371f494745d06bb25d398672d9b08054..4104a1ab6210cf5397fde270dfa6419c8e5c4c80 100644 (file)
 
 image/jpeg                      application/vnd.universal-input      0    -
 image/png                       application/vnd.universal-input      0    -
-image/gif                       application/vnd.universal-input      0    -
 image/tiff                      application/vnd.universal-input      0    -
-image/x-bitmap                  application/vnd.universal-input      0    -
-image/x-photocd                 application/vnd.universal-input      0    -
-image/x-portable-anymap         application/vnd.universal-input      0    -
-image/x-portable-bitmap         application/vnd.universal-input      0    -
-image/x-portable-graymap        application/vnd.universal-input      0    -
-image/x-portable-pixmap         application/vnd.universal-input      0    -
-image/x-sgi-rgb                 application/vnd.universal-input      0    -
-image/x-xbitmap                 application/vnd.universal-input      0    -
-image/x-xpixmap                 application/vnd.universal-input      0    -
-image/x-xwindowdump             application/vnd.universal-input      0    -
-image/x-sun-raster              application/vnd.universal-input      0    -
 image/pwg-raster                application/vnd.universal-input      0    -
 application/vnd.cups-pdf        application/vnd.universal-input      0    -
 image/urf                       application/vnd.universal-input      0    -