Ignore:
Timestamp:
Apr 10, 2008, 11:08:14 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Removed 4300 lines of unused code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/pcxread.cpp

    r124 r134  
    2323} PCX_header;
    2424
    25 int read_PCX_header(FILE *fp)
    26 {
    27   if (!fread(&PCX_header.manufactururer,1,1,fp)) return 0;
    28   if (!fread(&PCX_header.version,1,1,fp)) return 0;
    29   if (!fread(&PCX_header.encoding,1,1,fp)) return 0;
    30   if (!fread(&PCX_header.bits_per_pixel,1,1,fp)) return 0;
    31   PCX_header.xmin=read_uint16(fp);
    32   PCX_header.ymin=read_uint16(fp);
    33   PCX_header.xmax=read_uint16(fp);
    34   PCX_header.ymax=read_uint16(fp);
    35   PCX_header.hres=read_uint16(fp);
    36   PCX_header.vres=read_uint16(fp);
    37   if (!fread(PCX_header.palette,1,48,fp)) return 0;
    38   if (!fread(&PCX_header.reserved,1,1,fp)) return 0;
    39   if (!fread(&PCX_header.color_planes,1,1,fp)) return 0;
    40   PCX_header.bytes_per_line=read_uint16(fp);
    41   PCX_header.palette_type=read_uint16(fp);
    42   if (!fread(PCX_header.filter,1,58,fp)) return 0;
    43   return 1;
    44 }
    45 
    4625int write_PCX_header(FILE *fp)
    4726{
     
    6544}
    6645
    67 
    68 
    69 PCX_type PCX_file_type(char const *filename)
    70 {
    71   FILE *fp=fopen(filename,"rb");
    72   if (!fp)
    73   { set_error(imREAD_ERROR);
    74     return not_PCX;
    75   }
    76 
    77   if (!read_PCX_header(fp))
    78   {
    79     fclose(fp);
    80     set_error(imREAD_ERROR);
    81     return not_PCX;
    82   }
    83   fclose(fp);
    84   if (PCX_header.manufactururer!=10)
    85     return not_PCX;
    86   if (PCX_header.color_planes==3 && PCX_header.bits_per_pixel==8)
    87     return PCX_24;
    88   else if (PCX_header.color_planes==1 && PCX_header.bits_per_pixel==8)
    89     return PCX_8;
    90   else return not_PCX;
    91 }
    92 
    93 void read_PCX_line(FILE *fp, unsigned char *start, short skip, int width)
    94 {
    95   int c,n=0,i;
    96 
    97   do
    98   {
    99     c=fgetc(fp)&0xff;
    100     if ((c&0xc0)==0xc0)
    101     {
    102       i=c&0x3f;
    103       c=fgetc(fp);
    104       while (i--)
    105       {
    106     *start=c;
    107     start+=skip;
    108         n++;   
    109       }
    110     }
    111     else
    112     {
    113       *start=c;
    114       start+=skip;
    115       n++;
    116     }
    117   } while (n<width);
    118 }
    119 
    120 
    121 image24 *read_PCX24(char const *filename)
    122 {
    123   if (PCX_file_type(filename)!=PCX_24) return NULL;
    124   FILE *fp=fopen(filename,"rb");
    125   read_PCX_header(fp);
    126   image24 *im=new image24(PCX_header.xmax-PCX_header.xmin+1,
    127               PCX_header.ymax-PCX_header.ymin+1);
    128   int y;
    129   for (y=0;y<im->height();y++)
    130   {
    131     read_PCX_line(fp,im->scan_line(y),3,PCX_header.bytes_per_line);
    132     read_PCX_line(fp,im->scan_line(y)+1,3,PCX_header.bytes_per_line);
    133     read_PCX_line(fp,im->scan_line(y)+2,3,PCX_header.bytes_per_line);
    134   }
    135   fclose(fp);
    136   return im;
    137 }
    138 
    139 image *read_PCX(char const *filename, palette *&pal)
    140 {
    141   if (PCX_file_type(filename)!=PCX_8) return NULL;
    142   FILE *fp=fopen(filename,"rb");
    143   read_PCX_header(fp);
    144 
    145   image *im=new image(PCX_header.xmax-PCX_header.xmin+1,
    146               PCX_header.ymax-PCX_header.ymin+1);
    147   int y;
    148   for (y=0;y<im->height();y++)
    149     read_PCX_line(fp,im->scan_line(y),1,PCX_header.bytes_per_line);
    150   unsigned char palette_confirm;
    151   if (!fread(&palette_confirm,1,1,fp) || palette_confirm!=12)
    152   {
    153     pal=new palette;
    154     pal->defaults();
    155   }
    156   else
    157   {
    158     pal=new palette;
    159     fread(pal->addr(),1,256*3,fp);
    160   }
    161   fclose(fp);
    162   return im;
    163 }
    164 
    16546void write_PCX(image *im, palette *pal, char const *filename)
    16647{
     
    17152    return ;
    17253  }
    173 
    17454
    17555  PCX_header.manufactururer=10;
     
    18868  PCX_header.palette_type=0;
    18969  memset(PCX_header.filter,0,58);
    190 
    19170
    19271  if (!write_PCX_header(fp))
     
    226105}
    227106
    228 
    229 
Note: See TracChangeset for help on using the changeset viewer.