資源簡介
BMP文件轉CCS可以識別的DAT文件,簡單易懂,對初學者有幫助

代碼片段和文件信息
/************************************************
*?BMP2DAT.CPP?*
*************************************************/
#include?
#include?
#define?Bytes?768*576
#define?TotalBytes?Bytes*3
typedef?struct?byte5?/*?DSP?OUTPUT?DATA?FILE?FORMAT?*/
{
?char?byte0;?/*?example?:?0023?*/
?char?byte1;?/*?byte0=‘0‘?byte1=‘0‘?*/
?char?byte2;?/*?byte2=‘2‘?byte3=‘3‘?*/
?char?byte3;?/*?enter?occupy?one?byte?*/
?char?enter;
}?byte5;
main()
{
?int?i=0;
?FILE?*ifp?*ofp;
?char?bmpfile[20];
?
?char?byte2?byte3;
?byte5?b[Bytes]?g[Bytes]?r[Bytes];?/*?Image?Size?=?160*120?*/
?char?bmphead[54];?/*?bit?map?file?header?*/
?char?itemp[TotalBytes];?/*?Image?Size*3?=?160*120*3?bytes?*/
//--------------------------------------------
//?GET?DATA?FROM?BMP?FILE
//--------------------------------------------
?printf(“\nEnter?BMP?filename(*.bmp):?“);
?scanf(“%s“?&bmpfile);
?if?((ifp=fopen(bmpfile“r“))==NULL)
?{?printf(“Cannot?open?this?bmp?file?\n“);
???exit(1);
?};
?fread(bmphead?1?54?ifp);
?fread(itemp?1?TotalBytes?ifp);
?fclose(ifp);
//----------------------------------------------------
//?DATA?TRANSFORMATION?:?From?string?to?hex
//?example:?‘0023‘?->?23h
//----------------------------------------------------
?for?(i=0;i ?{
//--B-----------------------------------------------
??b[i].byte0?=?‘0‘;
??b[i].byte1?=?‘0‘;
??byte2?=?(itemp[3*i]?>>?4)?&?0x0f;
??byte3?=?itemp[3*i]?&?0x0f;
??if?((byte2?>=?0)?&&?(byte2?<=?9))
??b[i].byte2?=?byte2?+?0x30;
??if?(byte2?>=?10)
??b[i].byte2?=?byte2?-?9?+?0x60;
??if?((byte3?>=?0)?&&?(byte3?<=?9))
??b[i].byte3?=?byte3?+?0x30;
??if?(byte3?>=?10)
??b[i].byte3?=?byte3?-?9?+?0x60;
??b[i].enter?=?0x0a;
//--G-----------------------------------------------
??g[i].byte0?=?‘0‘;
??g[i].byte1?=?‘0‘;
??byte2?=?(itemp[3*i+1]?>>?4)?&?0x0f;
??byte3?=?itemp[3*i+1]?&?0x0f;
??if?((byte2?>=?0)?&&?(byte2?<=?9))
??g[i].byte2?=?byte2?+?0x30;
??if?(byte2?>=?10)
??g[i].byte2?=?byte2?-?9?+?0x60;
??if?((byte3?>=?0)?&&?(byte3?<=?9))
??g[i].byte3?=?byte3?+?0x30;
??if?(byte3?>=?10)
??g[i].byte3?=?byte3?-?9?+?0x60;
??g[i].enter?=?0x0a;
//--R-----------------------------------------------
??r[i].byte0?=?‘0‘;
??r[i].byte1?=?‘0‘;
??byte2?=?(itemp[3*i+2]?>>?4)?&?0x0f;
??byte3?=?itemp[3*i+2]?&?0x0f;
??if?((byte2?>=?0)?&&?(byte2?<=?9))
??r[i].byte2?=?byte2?+?0x30;
??if?(byte2?>=?10)
??r[i].byte2?=?byte2?-?9?+?0x60;
??if?((byte3?>=?0)?&&?(byte3?<=?9))
??r[i].byte3?=?byte3?+?0x30;
??if?(byte3?>=?10)
??r[i].byte3?=?byte3?-?9?+?0x60;
??r[i].enter?=?0x0a;
//--------------------------------------------
//?RESTORE?TRANSFERED?DATA?TO?AN?BMP?FILE
//--------------------------------------------
??if?((ofp=fopen(“B.dat““w“))==NULL)
??{?printf(“Cannot?open?file?test.in\n“);
????exit(1);
??};
??fwrite(b?5?Bytes?ofp);
??fclose(ofp);
??if?((ofp=fopen(“G.dat““w“))==NULL)
??{?printf(“Cannot?open?file?test.in\n“);
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????196662??2009-10-28?16:58??bmp2dat\111.bmp
?????文件??????66614??2004-06-30?00:47??bmp2dat\2.BMP
?????文件????1327160??2008-11-24?15:12??bmp2dat\20.BMP
?????文件?????196662??2005-04-29?15:45??bmp2dat\22.bmp
?????文件??????47928??2003-01-16?17:35??bmp2dat\6.BMP
?????文件????2500054??2009-11-23?16:32??bmp2dat\B.dat
?????文件???????3251??2009-11-23?09:52??bmp2dat\bmp2dat.cpp
?????文件???????4335??2009-11-10?10:18??bmp2dat\bmp2dat.dsp
?????文件????????539??2009-11-10?09:24??bmp2dat\bmp2dat.dsw
?????文件??????41984??2009-11-23?16:32??bmp2dat\bmp2dat.ncb
?????文件??????49664??2009-11-23?16:32??bmp2dat\bmp2dat.opt
?????文件???????1426??2009-11-23?09:52??bmp2dat\bmp2dat.plg
?????文件?????172090??2009-11-23?09:52??bmp2dat\Debug\bmp2dat.exe
?????文件?????185440??2009-11-23?09:52??bmp2dat\Debug\bmp2dat.ilk
?????文件???????5435??2009-11-23?09:52??bmp2dat\Debug\bmp2dat.obj
?????文件??????43520??2009-11-10?09:48??bmp2dat\Debug\bmp2dat.opt
?????文件?????220992??2009-11-16?09:26??bmp2dat\Debug\bmp2dat.pch
?????文件?????451584??2009-11-23?09:52??bmp2dat\Debug\bmp2dat.pdb
?????文件??????33792??2009-11-23?09:52??bmp2dat\Debug\vc60.idb
?????文件??????53248??2009-11-23?09:52??bmp2dat\Debug\vc60.pdb
?????文件????2500054??2009-11-23?16:32??bmp2dat\G.dat
?????文件????1045504??2009-11-23?16:32??bmp2dat\R.dat
?????目錄??????????0??2009-11-23?09:52??bmp2dat\Debug
?????目錄??????????0??2009-11-23?16:32??bmp2dat
-----------?---------??----------?-----??----
??????????????9147938????????????????????24
- 上一篇:植物大戰僵尸圖片資源
- 下一篇:at20000.rar
評論
共有 條評論