4 #include "interlacemodes.h"
8 FileGIF::FileGIF(Asset_GC asset)
12 asset->video_data = 1;
13 asset->format = FILE_GIF;
21 int FileGIF::reset_parameters_derived()
26 int FileGIF::open_file(int rd, int wr)
31 // skip header for write
43 int64_t FileGIF::get_video_length()
45 return -1; // infinity
46 // should be determined by whether the GIF is animated
49 int64_t FileGIF::get_memory_usage()
51 // give buffer length plus padding
53 return (int64_t)asset->width * asset->height * sizeof(VPixel);
58 int FileGIF::close_file_derived()
64 int FileGIF::read_header()
68 if(!(stream = GIFOpen(asset->path, "r")))
70 eprintf("Error while opening \"%s\" for reading. \n%m\n", asset->path);
74 GIFGetField(stream, GIFTAG_IMAGEWIDTH, &(asset->width));
75 GIFGetField(stream, GIFTAG_IMAGELENGTH, &(asset->height));
76 asset->interlacemode = BC_ILACE_MODE_NOTINTERLACED;
84 VFrame* FileGIF::read_frame(int use_alpha, int use_float)
90 int FileGIF::read_raw()
96 unsigned char *raw_data;
99 if(!(stream = GIFOpen(asset->path, "r")))
101 eprintf("Error while opening \"%s\" for writing. \n%m\n", asset->path);
105 raw_data = new unsigned char[asset->width * asset->height * 4];
106 GIFReadRGBAImage(stream, asset->width, asset->height, (uint32*)raw_data, 0);
110 // convert to a Bcast 2000 Frame
111 data = new VFrame(asset->width, asset->height);
113 for(i = 0; i < asset->height; i++)
115 import_row(data->rows[asset->height - i - 1], &raw_data[i * asset->width * 4]);
118 // delete temporary buffers
124 int FileGIF::import_row(VPixel *output, unsigned char *row_pointer)
126 for(int i = 0, j = 0; j < asset->width; j++)
129 output[j].red = ((VWORD)row_pointer[i++]) << 8;
130 output[j].green = ((VWORD)row_pointer[i++]) << 8;
131 output[j].blue = ((VWORD)row_pointer[i++]) << 8;
132 output[j].alpha = ((VWORD)row_pointer[i++]) << 8;
134 output[j].red = (VWORD)row_pointer[i++];
135 output[j].green = (VWORD)row_pointer[i++];
136 output[j].blue = (VWORD)row_pointer[i++];
137 output[j].alpha = (VWORD)row_pointer[i++];
144 // c-file-style: "linux"