Exemple #1
0
/*
 * palette chunks from the classical Autodesk Animator.
 */
void fli_read_color(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap, unsigned char *cmap)
{
	unsigned short num_packets, cnt_packets, col_pos;
	col_pos=0;
	num_packets=fli_read_short(f);
	for (cnt_packets=num_packets; cnt_packets>0; cnt_packets--) {
		unsigned short skip_col, num_col, col_cnt;
		skip_col=fli_read_char(f);
		num_col=fli_read_char(f);
		if (num_col==0) {
			for (col_pos=0; col_pos<768; col_pos++) {
				cmap[col_pos]=fli_read_char(f)<<2;
			}
			return;
		}
		for (col_cnt=skip_col; (col_cnt>0) && (col_pos<768); col_cnt--) {
			cmap[col_pos]=old_cmap[col_pos];col_pos++;
			cmap[col_pos]=old_cmap[col_pos];col_pos++;
			cmap[col_pos]=old_cmap[col_pos];col_pos++;
		}
		for (col_cnt=num_col; (col_cnt>0) && (col_pos<768); col_cnt--) {
			cmap[col_pos++]=fli_read_char(f)<<2;
			cmap[col_pos++]=fli_read_char(f)<<2;
			cmap[col_pos++]=fli_read_char(f)<<2;
		}
	}
}
Exemple #2
0
void fli_read_header(FILE *f, s_fli_header *fli_header)
{
        fli_header->filesize=fli_read_long(f);  /* 0 */
        fli_header->magic=fli_read_short(f);    /* 4 */
        fli_header->frames=fli_read_short(f);   /* 6 */
        fli_header->width=fli_read_short(f);    /* 8 */
        fli_header->height=fli_read_short(f);   /* 10 */
        fli_header->depth=fli_read_short(f);    /* 12 */
        fli_header->flags=fli_read_short(f);    /* 14 */
        if (fli_header->magic == HEADER_FLI) {
                /* FLI saves speed in 1/70s */
                fli_header->speed=fli_read_short(f)*14;         /* 16 */
        } else {
                if (fli_header->magic == HEADER_FLC) {
                        /* FLC saves speed in 1/1000s */
                        fli_header->speed=fli_read_long(f);     /* 16 */
                } else {
                        fprintf(stderr, "error: magic number is wrong !\n");
                        fli_header->magic = NO_HEADER;
                }
        }

        if (fli_header->width == 0)
          fli_header->width = 320;

        if (fli_header->height == 0)
          fli_header->height = 200;
}
Exemple #3
0
void fli_read_frame(FILE *f, s_fli_header *fli_header, unsigned char *old_framebuf, unsigned char *old_cmap, unsigned char *framebuf, unsigned char *cmap)
{
	s_fli_frame fli_frame;
	unsigned long framepos;
	int c;
	framepos=ftell(f);

	fli_frame.size=fli_read_long(f);
	fli_frame.magic=fli_read_short(f);
	fli_frame.chunks=fli_read_short(f);

	if (fli_frame.magic == FRAME) {
		fseek(f, framepos+16, SEEK_SET);
		for (c=0;c<fli_frame.chunks;c++) {
			s_fli_chunk chunk;
			unsigned long chunkpos;
			chunkpos = ftell(f);
			chunk.size=fli_read_long(f);
			chunk.magic=fli_read_short(f);
			switch (chunk.magic) {
				case FLI_COLOR:   fli_read_color(f, fli_header, old_cmap, cmap); break;
				case FLI_COLOR_2: fli_read_color_2(f, fli_header, old_cmap, cmap); break;
				case FLI_BLACK:	  fli_read_black(f, fli_header, framebuf); break;
				case FLI_BRUN:    fli_read_brun(f, fli_header, framebuf); break;
				case FLI_COPY:    fli_read_copy(f, fli_header, framebuf); break;
				case FLI_LC:      fli_read_lc(f, fli_header, old_framebuf, framebuf); break;
				case FLI_LC_2:    fli_read_lc_2(f, fli_header, old_framebuf, framebuf); break;
				case FLI_MINI:	  /* unused, skip */ break;
				default: /* unknown, skip */ break;
			}
			if (chunk.size & 1) chunk.size++;
			fseek(f,chunkpos+chunk.size,SEEK_SET);
		}
	} /* else: unknown, skip */
	fseek(f, framepos+fli_frame.size, SEEK_SET);
}