Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc, char *argv[])
- {
- //Decralation of variables
- FILE *fpi1,*fpi2,*fpo;
- int id,ix,iy,i,j,width,height,time,num;
- unsigned char dn;
- unsigned char *buffer;
- int *imeco;
- unsigned char r,g,b;
- char line[4];
- //GPS data logger
- if((fpi1=fopen(argv[1],"r"))==NULL)
- {
- printf ("The file can't be opened. The program is exit.\n");
- return 0;
- }
- //image data
- if((fpi2=fopen(argv[2],"rb"))==NULL)
- {
- printf ("The file can't be opened. The program is exit.\n");
- return 0;
- }
- //image data + GPS
- if((fpo=fopen(argv[3],"wb"))==NULL)
- {
- printf("The file can't be opened. The program is exit.\n");
- return 0;
- }
- width = atoi(argv[4]); printf("W = %d,", width);
- height = atoi(argv[5]); printf("H = %d\n", height);
- r=atoi(argv[6]);
- g=atoi(argv[7]);
- b=atoi(argv[8]);
- time=atoi(argv[9]);
- printf("time=%d\n",time);
- num=atoi(argv[10]);
- //2 : x y
- imeco=(int*)malloc(2*num);
- fread((int*)imeco,sizeof(int),2*num,fpi1);
- //for image data :
- buffer= (unsigned char*)malloc(width*height*3);
- fread((unsigned char*)buffer,sizeof(char),width*height*3,fpi2);
- fseek(fpi1,time*7,SEEK_SET);
- fgets(line, 4, fpi1);
- ix=atoi(line);
- fgets(line, 4, fpi1);
- iy=atoi(line);
- //x y position on that time
- printf("ix=%d\n",ix);
- printf("iy=%d\n",iy);
- //colored point on that position
- buffer[3*(iy*width+ix)]=r;
- buffer[3*(iy*width+ix)+1]=g;
- buffer[3*(iy*width+ix)+2]=b;
- //record colored point to file (write)
- for(i=0;i<height*3;i++)
- {
- for(j=0;j<width;j++)
- {
- dn=buffer[i*width+j];
- fwrite(&dn,sizeof(char),1,fpo);
- }
- }
- printf("check6\n");
- free(buffer);
- free(imeco);
- fclose(fpi1);
- fclose(fpi2);
- fclose(fpo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement