Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* creates pallete from first frame, zeros all colours in palette from first frame */
- // after this works extend the palette buffer to a few frames
- // then make palette functions for editor, select frames, genorate palette
- // comparison of pixels, and actions( subtract, add, set to x colour )
- #include <unistd.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/mman.h>
- #include <string.h>
- #include "record.h"
- #define checkpoint printf("checkpoint\n");
- //#define WIDTH 640
- //#define HEIGHT 480
- //#define VARIATION 2
- //#define FRAMES 10
- //#define CORRECTION 4
- static char *map;
- int main(int argc, char *argv[])
- {
- int done = 0;
- FILE *video;
- char file[40];
- char *background;
- int x,y,z;
- int match=0;
- if (argv[1] == NULL) { argv[1] = "output"; } // if no file, try open file named output
- if ((video=fopen(argv[1],"r")) == NULL) printf("File did not open"); exit; // opens file
- map=malloc(WIDTH*HEIGHT*3); // alloc memory for one frame
- background=malloc((WIDTH*HEIGHT*3)*FRAMES);
- checkpoint;
- fseek(video,WIDTH*HEIGHT*3*62,SEEK_SET);
- fread(background, WIDTH*HEIGHT*3*FRAMES, 1, video);
- checkpoint;
- while ( ! done ) {
- if ( ! feof(video) )
- {
- fread(map, WIDTH*HEIGHT*3, 1, video);
- // remove all colours from palette
- for(x=0; x<WIDTH*HEIGHT*3*FRAMES; x=x+3)
- {
- if (( (int)background[x] > (int)map[x%(WIDTH*HEIGHT*3)]-VARIATION/2 ) && ( (int)background[x] < (int)map[x%(WIDTH*HEIGHT*3)]+VARIATION/2 ))
- {
- if (( (int)background[x+1] > (int)map[(x+1)%(WIDTH*HEIGHT*3)]-VARIATION/2 ) && ( (int)background[x+1] < (int)map[(x+1)%(WIDTH*HEIGHT*3)]+VARIATION/2 ))
- {
- if (( (int)background[x+2] > (int)map[(x+2)%(WIDTH*HEIGHT*3)]-VARIATION/2 ) && ( (int)background[x+2] < (int)map[(x+2)%(WIDTH*HEIGHT*3)]+VARIATION/2 ))
- {
- map[(x)%(WIDTH*HEIGHT*3)] = (char)0;
- map[(x+1)%(WIDTH*HEIGHT*3)] = (char)0;
- map[(x+2)%(WIDTH*HEIGHT*3)] = (char)255;
- }
- }
- }
- }
- for(y=0; y <HEIGHT; y++)
- {
- for(x=0; x <WIDTH; x=x+3)
- {
- if ( ( (int)map[x+(y*WIDTH)] != 0 ) && ( (int)map[x+(y*WIDTH)+1] != 0 ) && ( (int)map[x+(y*WIDTH)+2] != 255 ) )
- {
- match++;
- }else{
- if ( match < CORRECTION )
- {
- for(z=1; z < CORRECTION; z++)
- {
- map[(x+(y*WIDTH))-(z*3)]= (char)0;
- map[(x+(y*WIDTH)+1)-(z*3)]= (char)0;
- map[(x+(y*WIDTH)+2)-(z*3)]= (char)255;
- }
- }
- match=0;
- }
- }
- }
- for(x=0; x < WIDTH*3; x=x+3)
- {
- for(y=x; y <HEIGHT*WIDTH*3; y=y+(WIDTH*3))
- {
- if ( ( (int)map[y] != 0 ) && ( (int)map[y+1] != 0 ) && ( (int)map[y+2] != 255 ) )
- {
- match++;
- }else{
- if ( match < CORRECTION )
- {
- for(z=1; z < CORRECTION; z++)
- {
- map[(y)-(z*3)]= (char)0;
- map[(y+1)-(z*3)]= (char)0;
- map[(y+2)-(z*3)]= (char)255;
- }
- }
- match=0;
- }
- }
- }
- //checkpoint;
- // write frame to new file
- strcpy(file, argv[1]);
- strcat(file,".edit");
- record(map, file);
- }else{
- done=1;
- }
- }
- fclose(video);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement