Пример #1
0
int main(int argc, char *argv[])
{
  rle_decompress_struct cinfo;
  FILE * infile;

  const char *filename;
  if( argc < 2 )
    {
    return 1;
    }
  filename = argv[1];

  if ((infile = fopen(filename, "rb")) == NULL) {
    fprintf(stderr, "can't open %s\n", filename);
    return 0;
  }

  rle_create_decompress(&cinfo);

  int i;
  int dims[2] = { 1760,1760 };
  int bpp = 16;
  rle_stdio_src(&cinfo, infile, dims);

  printf("num segment: %d\n", cinfo.header->num_segments );
  printf("offsets table:\n");
  for(i = 0; i < 16; ++i)
    printf("offset: %d\n", cinfo.header->offset[i] );

  (void) rle_start_decompress(&cinfo);

  char *buffer = (char*)malloc( dims[0] * (bpp / 8) );
  while( cinfo.current_segment < cinfo.header->num_segments ) {
    while (cinfo.output_scanline < cinfo.output_height) {
      (void) rle_read_scanlines(&cinfo, buffer, 1);
      /*put_scanline_someplace(buffer[0], row_stride);*/
    }
  }
  free(buffer);

  (void) rle_finish_decompress(&cinfo);

  rle_destroy_decompress(&cinfo);

  fclose(infile);

  return 0;
}
Пример #2
0
int main(int argc, char *argv[])
{
    rle_decompress_struct cinfo;
    FILE * infile;
    int i;

    const char *filename;
    if( argc < 2 )
    {
        return 1;
    }
    filename = argv[1];

    if ((infile = fopen(filename, "rb")) == NULL) {
        fprintf(stderr, "can't open %s\n", filename);
        return 0;
    }

    rle_create_decompress(&cinfo);

    /* Dimensions: (1760,1760,1)*/
    int dims[2] = { 1760,1760 };
    rle_stdio_src(&cinfo, infile, dims);

    /*rle_header *h = cinfo.header;*/
    printf("num segment: %d\n", cinfo.header->num_segments );
    printf("offsets table:\n");
    for(i = 0; i < 16; ++i)
        printf("offset: %d\n", cinfo.header->offset[i] );

    /* Simply dump the file info:*/

    rle_destroy_decompress(&cinfo);

    fclose(infile);

    return 0;
}