發信人: xy152.bbs@bbs.ee.nthu.edu.tw (我願克服一切困難...) 日期: 19 Dec 1999 03:57:08 GMT 標題: Re: 請問 有關bmp圖檔 信群: tw.bbs.comp.language 看板: programming/A0S5OLSK 來源: <3Y668K$mDR@bbs.ee.nthu.edu.tw>:20559, 組織: ☆清華電機☆ ==> 在 leaf.bbs@cszone.twbbs.org (bug) 的文章中提到: > ※ 引述《xy152.bbs@bbs.ee.nthu.edu.tw (迎向遠方的天空)》之銘言: > : 那如果我用 Borland C++ v 5.2 呢 ? > : 需要用read()或 write()嗎? > 應該有類似 LoadImage 這類的 function 可以讀入 bmp 檔 哈哈 我試出來了! 分享一下... #include #include void main() { int i,j; ifstream data_in("Lena512p.bmp",ios::in|ios::binary); ofstream data_out("picture.bmp",ios::out|ios::binary); unsigned char header[1078]; unsigned char content[512][512]; for(i=0;i<1078;i++) data_in.read(header+i,1); //Read header from the file for(i=0;i<512;i++) for(j=0;j<512;j++) data_in.read(*(content+i)+j,1); //Read content data_in.close(); // processing data... for(i=0;i<1078;i++) data_out.write(header+i,1); // Output header for(i=0;i<512;i++) for(j=0;j<512;j++) data_out.write(*(content+i)+j,1); // Output content data_out.close(); getch(); } 以上程式 只做I/O動作... -- ※ Origin: 清華電機 ◆ From: thccy12.Oz.nthu.edu.tw .