[ create a new paste ] login | about

Link: http://codepad.org/i8K01zBM    [ raw code | output | fork ]

C++, pasted on Nov 19:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979 
int _tmain(int argc, _TCHAR* argv[])
{

	int x=0,y=0;
	float b=1.5,c=0.5,h;
	int  d=20,e=30,g=10;
	double f;
	unsigned char image1[256][256];
	unsigned char image_out[256][256];
	unsigned char image2[256][256];
	unsigned char image_out2[256][256];
	unsigned char image_out3[512][512];
	unsigned char image_out4[512][512];
	int i,j;
	int head,m,s,t,u,v,w;
	char a[512];			
	FILE *fp1,*fp2,*fp3,*fp4,*fp5;

	fp1 = fopen("lena.pgm","r");
	fp2 = fopen("out-file1.pgm","w");
    fp3 = fopen("out-file2.pgm","w");
	fp4 = fopen("out-file3.pgm","w");
	fp5 = fopen("out-file4.pgm","w");

	fgets(a,512,fp1);
		if(a[0]!='P')
			return  NULL;                                
	sscanf(a,"P%d",&head);
		if(head < 1 || head > 6)		
			return NULL;
	do fgets(a,512,fp1);while(a[0]=='#');					
		sscanf(a,"%d%d", &x, &y);
	fgets(a,512,fp1);
	sscanf(a,"%d",&m);

	fprintf(fp2,"P%d\n%d %d\n%d\n",head,x,y,m);
	fprintf(fp3,"P%d\n%d %d\n%d\n",head,x,y,m);
	fprintf(fp4,"P%d\n%d %d\n%d\n",head,512,512,m);
    fprintf(fp5,"P%d\n%d %d\n%d\n",head,512,512,m);

	for(i = 0; i < x; i++){
		for(j = 0; j < y; j++){
			fscanf(fp1,"%d",&image1[i][j]);
		}
	}

/*画像の平行移動*/
for(i = 0; i < x; i++){
		if(i+d>x)break;
	   for(j = 0; j < y; j++){
		if(j+e>y)break;
		   image_out[i+d][j+e] =image1[i][j];
	   }
	}
for(i = 0; i < x; i++){
		for(j = 0; j < y; j++){
			fprintf(fp2,"%d ",image_out[i][j]);
		}
	}
	
	/*画像の拡大縮小*/
	for(i = 0; i < x; i++){
		for(j = 0; j < y; j++){
		   s=i*b;
		   t=j*c;
		
		  image_out2[s][t] =image1[i][j];
	   }
	}
    for(i = 0; i < x; i++){
		for(j = 0; j < y; j++){
			fprintf(fp3,"%d ",image_out2[i][j]);
		}
	}
	/*せん断*/
for(i = 0; i < x; i++){
		for(j = 0; j < y; j++){
		   u=i+(tan(25*PI/180))*j;
		   t=j;
		
		  image_out3[u][t] =image1[i][j];
	   }
	}
	for(i = 0; i < 512; i++){
		for(j = 0; j < 512; j++){
			fprintf(fp4,"%d ",image_out3[i][j]);
		}
	}


/*画像の拡大*/
for(i =0; i < x; i++){
		for(j =0; j < y; j++){
		   v=i*cos(15*PI/180)+j*sin(15*PI/180);
		   w=-i*sin(15*PI/180)+j*cos(15*PI/180);
		
		  image_out4[v][w] =image1[i][j];
	   }
	}
	for(i = 0; i < 512; i++){
		for(j = 0; j < 512; j++){
			fprintf(fp5,"%d ",image_out4[i][j]);
		}
	}


	

	fclose(fp1);
	fclose(fp2);
	fclose(fp3);
	fclose(fp4);
	fclose(fp5);

}			


Output:
1
2
3
Line 19: error: stdafx.h: No such file or directory
Line 6: error: '_TCHAR' has not been declared
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: