Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- int main(int argc, char** argv)
- {
- int c, i, byte, filesize;
- char bit, pix;
- unsigned char *light_buffer, *dark_buffer;
- char command[100];
- FILE *file, *output;
- if(file = fopen("MOVIE.gsl", "r")) {
- fseek(file, 0, SEEK_END);
- filesize = ftell(file);
- fseek(file, 0, SEEK_SET);
- if(filesize % 2048 == 0) {
- mkdir("tmp", 01777);
- light_buffer = malloc(1024);
- dark_buffer = malloc(1024);
- for(i=0 ; i<filesize/2048 ; i++) {
- output = fopen("tmp/bmp24", "w+");
- fread(light_buffer, 1, 1024, file);
- fread(dark_buffer, 1, 1024, file);
- for(byte=0 ; byte<1024 ; byte++) {
- for(bit=0 ; bit<8 ; bit++) {
- pix = (light_buffer[byte] & (1<<(7-bit)) ? 1 : 0);
- pix |= (dark_buffer[byte] & (1<<(7-bit)) ? 2 : 0);
- switch(pix) {
- case 0:
- fprintf(output, "%c%c%c", 255, 255, 255);
- break;
- case 1:
- fprintf(output, "%c%c%c", 192, 192, 192);
- break;
- case 2:
- fprintf(output, "%c%c%c", 128, 128, 128);
- break;
- case 3:
- fprintf(output, "%c%c%c", 0, 0, 0);
- break;
- }
- }
- }
- fclose(output);
- sprintf(command, "rgb2gif -1 -s 128 64 tmp/bmp24 > tmp/%06i.gif", i);
- system(command);
- remove("tmp/bmp24");
- }
- free(light_buffer);
- free(dark_buffer);
- system("gifasm -A 7 $(find tmp/*.gif) > result.gif");
- } else fprintf(stderr, "Invalid file size.\n");
- fclose(file);
- } else fprintf(stderr, "Can't find \"MOVIE.gsl\".\n");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement