7 FileGIF::FileGIF(Asset *asset) : FileBase(asset)
10 asset->video_data = 1;
11 asset->format = FILE_GIF;
19 int FileGIF::reset_parameters_derived()
24 int FileGIF::open_file(int rd, int wr)
29 // skip header for write
41 int64_t FileGIF::get_video_length()
43 return -1; // infinity
44 // should be determined by whether the GIF is animated
47 int64_t FileGIF::get_memory_usage()
49 // give buffer length plus padding
51 return asset->width * asset->height * sizeof(VPixel);
56 int FileGIF::close_file_derived()
62 int FileGIF::read_header()
66 if(!(stream = GIFOpen(asset->path, "r")))
68 perror("FileGIF::read_header");
72 GIFGetField(stream, GIFTAG_IMAGEWIDTH, &(asset->width));
73 GIFGetField(stream, GIFTAG_IMAGELENGTH, &(asset->height));
81 VFrame* FileGIF::read_frame(int use_alpha, int use_float)
87 int FileGIF::read_raw()
93 unsigned char *raw_data;
96 if(!(stream = GIFOpen(asset->path, "r")))
98 perror("FileGIF::read_raw");
102 raw_data = new unsigned char[asset->width * asset->height * 4];
103 GIFReadRGBAImage(stream, asset->width, asset->height, (uint32*)raw_data, 0);
107 // convert to a Bcast 2000 Frame
108 data = new VFrame(asset->width, asset->height);
110 for(i = 0; i < asset->height; i++)
112 import_row(data->rows[asset->height - i - 1], &raw_data[i * asset->width * 4]);
115 // delete temporary buffers
121 int FileGIF::import_row(VPixel *output, unsigned char *row_pointer)
123 for(int i = 0, j = 0; j < asset->width; j++)
126 output[j].red = ((VWORD)row_pointer[i++]) << 8;
127 output[j].green = ((VWORD)row_pointer[i++]) << 8;
128 output[j].blue = ((VWORD)row_pointer[i++]) << 8;
129 output[j].alpha = ((VWORD)row_pointer[i++]) << 8;
131 output[j].red = (VWORD)row_pointer[i++];
132 output[j].green = (VWORD)row_pointer[i++];
133 output[j].blue = (VWORD)row_pointer[i++];
134 output[j].alpha = (VWORD)row_pointer[i++];