raw파일을 bmp파일로 변경하고자 합니다.(2)
풋내
질문 제목 : raw파일을 bmp파일로 변경하고자 합니다.(2)질문 요약 :raw파일을 bmp파일로 변경하고자 합니다.(2)
질문 내용 :
raw파일을 bmp파일로 변경하고자 합니다. dev-c를 사용하는데요. bmp파일이 열면 이 파일을 열수 없습니다.라고 나오네요.
어디서 문제가 발생했는지 모르겠습니다.
c언어 영상처리 공부하는 초보입니다.
도와주세요.
raw파일도 첨부합니다.
#include stdio.h
#include stdlib.h
typedef unsigned short word;
typedef unsigned long dword;
typedef unsigned long long;
typedef unsigned char byte;
#ifndef bi_rgb
#define bi_rgb 0
#endif
#pragma pack(1)
typedef struct tagbitmapfileheader
{
word bftype;
dword bfsize;
word bfreserved1;
word bfreserved2;
dword bfoffbits;
}bitmapfileheader;
typedef struct tagbitmapinfoheader
{
dword bisize;
long biwidth;
long biheight;
word biplanes;
word bibitcount;
dword bicompression;
dword bisizeimage;
long bixpelspermeter;
long biypelspermeter;
dword biclrused;
dword&nbdword biclrimportant;
}bitmapinfoheader;
typedef struct tagrgbquad
{
byte rgbblue;
byte rgbgreen;
byte rgbred;
byte rgbreserved;
}rgbquad;
#pragma pack()
// 그레이 raw 파일을 그레이 비트맵 파일로 변환
int main(int argc, char **argv)
{
bitmapfileheader file_h;
bitmapinfoheader info_h;
dword dwbmpsize=0;
dword dwrawsize=0;
dword dwline=0;
long lcount, i;
file *in, *out;
char *pdata=null;
rgbquad rgbpal[256];
file_h.bftype = 0x4d42;
file_h.bfreserved1 = 0;
file_h.bfreserved2 = 0;
file_h.bfoffbits = sizeof(rgbpal) + sizeof(bitmapfileheader) + sizeof(bitmapinfoheader);
info_h.bisize = sizeof(bitmapinfoheader);
info_h.biwidth = 256;
info_h.biheight = 256;
info_h.biplanes = 1;
info_h.bibitcount = 8;
info_h.bicompression = bi_rgb;
info_h.bixpelspermeter = 0;
info_h.biypelspermeter = 0;
info_h.biclrused = 0;
info_h.biclrimportant = 0;
in=fopen(lena256.raw, rb);
fread(pdata,sizeof(unsigned char),256*256,in);
dwrawsize=info_h.biwidth*info_h.biheight;
pdata=(char *)malloc(sizeof(char)*dwrawsize+16);
out=fopen(outbmp.bmp, wb);
fwrite((char *)&file_h, 1, sizeof(bitmapfileheader), out);
fwrite((char *)&info_h, 1, sizeof(bitmapinfoheader), out);
fwrite((char *)rgbpal, 1, sizeof(rgbpal), out);
lcount=dwrawsize;
fclose(in);
fclose(out);
return 1;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |