#include <stdio.h>
int main()
{
int i,j,c,meun;
unsigned char lmage[512][512];
unsigned char Resultlmage[512][512];
printf("====================메뉴====================\n");
printf("1.상하반전 2.좌우상하반전 3.좌우반전 4.밝기조정\n");
printf("번호 선택 :");
scanf("%d",&meun);
//파일 경로
FILE *fp = fopen("E:\Lena.raw","rb");
if(fp==NULL)
{
//입력파일이 없으면 에러
printf("no file");
return 1;
}
//이미지로부터 데이터를 읽음
fread(lmage,sizeof(char),512*512,fp);
//파일 닫음
fclose(fp);
if(meun == 1)
{
for(i=0; i<512; i++)
{
for(j=0; j<512; j++)
{
Resultlmage[i][j] = lmage[512-1-i][j];
}
}
//출력파일을 쓰기 모드로 열기
FILE *outfile = fopen("Lenna_상하반전.raw","wb");
//결과 이미지를 파일에 기록
fwrite(Resultlmage, sizeof(char), 512*512, outfile);
//파일을 닫음
fclose(outfile);
}else if(meun == 2){
for(i=0; i<512; i++)
{
for(j=0; j<512; j++)
{
Resultlmage[i][j] = lmage[512-1-i][512-1-j];
}
}
FILE *outfile = fopen("Lenna_상하좌우반전.raw","wb");
fwrite(Resultlmage, sizeof(char), 512*512, outfile);
fclose(outfile);
}else if(meun == 3){
for(i=0; i<512; i++)
{
for(j=0; j<512; j++)
{
Resultlmage[i][j] = lmage[i][512-1-j];
}
}
FILE *outfile = fopen("Lenna_좌우반전.raw","wb");
fwrite(Resultlmage, sizeof(char), 512*512, outfile);
fclose(outfile);
}else if(meun == 4){
printf("숫자 입력 : ");
scanf("%d", &c);
for(i=0; i<512; i++)
{
for(j=0; j<512; j++)
{
Resultlmage[i][j] = lmage[i][j]-c;
}
}
FILE *outfile = fopen("Lenna_색조정.raw","wb");
fwrite(Resultlmage, sizeof(char), 512*512, outfile);
fclose(outfile);
}
fflush(stdin);
printf("이미지 변환완료\n");
printf("해당 버튼을 클릭하여 확인하기 바랍니다.\n");
return 0;
}
'프로그래밍' 카테고리의 다른 글
warning C4996 (0) | 2013.05.21 |
---|---|
단순 연결 리스트 구현 (0) | 2013.05.21 |
자유 공간 리스트 알고리즘 (단순 연결 리스트) (1) | 2013.05.20 |
3차원 배열 원소의 논리적,물리적 순서를 확인하는 예제 (0) | 2013.05.19 |
2차원 배열의 논리적,물리적 순서를 확인하는 예제 (0) | 2013.05.19 |