資源簡介
在VC或者VS下配置Opengl,打開文件主文件,試著運行和讀懂程序,謝謝

代碼片段和文件信息
// bmpops.cpp?:?implementation?of?the?BMPFile?class
//
// This?handles?the?reading?and?writing?of?BMP?files.
//
//
#include?“stdafx.h“
#include?“bmpfile.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
BMPFile::BMPFile()
{
m_errorText=“OK“;
}
BMPFile::~BMPFile()
{
}
////////////////////////////////////////////////////////////////////////////
// write?a?24-bit?BMP?file
//
// image?MUST?be?a?packed?buffer?(DWORD-aligned)
void?BMPFile::SaveBMP(CString?fileName //?output?path
BYTE?*?buf //?BGR?buffer
int?width //?pixels
int?height)
{
short?res1=0;
????short?res2=0;
????long?pixoff=54;
????long?compression=0;
????long?cmpsize=0;
????long?colors=0;
????long?impcol=0;
char?m1=‘B‘;
char?m2=‘M‘;
m_errorText=“OK“;
int?imagesize=(width*24+31)/32*4*height;
long?bmfsize=sizeof(BITMAPFILEHEADER)?+?sizeof(BITMAPINFOHEADER)?+
?? imagesize;
long?byteswritten=0;
BITMAPINFOHEADER?header;
?? header.biSize=40;? //?header?size
header.biWidth=width;
header.biHeight=height;
header.biPlanes=1;
header.biBitCount=24; //?RGB?encoded?24?bit
header.biCompression=BI_RGB; //?no?compression
header.biSizeImage=0;
header.biXPelsPerMeter=0;
header.biYPelsPerMeter=0;
header.biClrUsed=0;
header.biClrImportant=0;
FILE?*fp;
fp=fopen(fileName“wb“);//寫文件到磁盤
if?(fp==NULL)?{
m_errorText=“Can‘t?open?file?for?writing“;
return;
}
//?should?probably?check?for?write?errors?here...
fwrite((BYTE??*)&(m1)11fp);?byteswritten+=1;
fwrite((BYTE??*)&(m2)11fp);?byteswritten+=1;
fwrite((long??*)&(bmfsize)41fp); byteswritten+=4;
fwrite((int??*)&(res1)21fp);?byteswritten+=2;
fwrite((int??*)&(res2)21fp);?byteswritten+=2;
fwrite((long??*)&(pixoff)41fp);?byteswritten+=4;
fwrite((BITMAPINFOHEADER?*)&headersizeof(BITMAPINFOHEADER)1fp);
byteswritten+=sizeof(BITMAPINFOHEADER);
int?r=fwrite(bufimagesize1fp);?//?buf?is?double?word?aligned.
if(r=-1){
m_errorText=“Write?image?data?failed!“;
}
fclose(fp);
}
////////////////////////////////////////////////////////////////////////////////////
//
// 148?bit?BMP?stuff
//
// if?you?have?a?color-mapped?image?and?a?color?map...
//
// the?BMP?saving?code?in?SaveColorMappedBMP?modified?from?Programming?
// for?Graphics?Files?in?C?and?C++?by?John?Levine.
void?BMPFile::SaveBMP(CString?fileName? //?output?path
??BYTE?*?colormappedbuffer //?one?BYTE?per?pixel?colormapped?image
??int?width
??int?height
? ??int?bitsperpixel //?1?4?8
??int?colors //?number?of?colors?(number?of?RGBQUADs)
??RGBQUAD?*colormap) //?array?of?RGBQUADs?
{
if(colormap==NULL)
return;
if(colormappedbuffer==NULL)
return;
int?datasize?cmapsize?byteswritten?row?col;
m_errorText=“OK“;
if?(bitsperpixel?==?24)?{
//?the?routines?could?be?combined
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????17289??2003-06-28?22:21??threedbmp\Bmpfile.cpp
?????文件???????1534??2003-05-30?20:39??threedbmp\Bmpfile.h
?????文件????????173??2012-01-21?19:37??threedbmp\copyright.bat
?????文件???????2512??2004-01-05?17:26??threedbmp\MainFrm.cpp
?????文件???????1581??2003-10-31?17:36??threedbmp\MainFrm.h
?????文件??????29644??2012-02-09?10:00??threedbmp\OGL_MFC.APS
?????文件???????3067??2012-02-09?10:01??threedbmp\OGL_MFC.clw
?????文件???????4664??2004-01-05?21:23??threedbmp\OGL_MFC.cpp
?????文件???????5306??2012-02-09?10:01??threedbmp\OGL_MFC.dsp
?????文件????????537??2003-10-31?17:36??threedbmp\OGL_MFC.dsw
?????文件???????1367??2004-01-05?20:59??threedbmp\OGL_MFC.h
?????文件???????2572??2012-02-09?10:01??threedbmp\OGL_MFC.plg
?????文件??????12463??2004-01-06?08:47??threedbmp\OGL_MFC.rc
?????文件???????1762??2003-10-31?17:36??threedbmp\OGL_MFCDoc.cpp
?????文件???????1486??2003-10-31?17:36??threedbmp\OGL_MFCDoc.h
?????文件??????12707??2004-01-05?22:46??threedbmp\OGL_MFCView.cpp
?????文件???????2497??2004-01-05?22:26??threedbmp\OGL_MFCView.h
?????文件???????4335??2003-10-31?17:36??threedbmp\ReadMe.txt
?????文件???????1078??2003-10-31?17:36??threedbmp\res\OGL_MFC.ico
?????文件????????399??2003-10-31?17:36??threedbmp\res\OGL_MFC.rc2
?????文件???????1078??2003-10-31?17:36??threedbmp\res\OGL_MFCDoc.ico
?????文件???????1078??2003-10-31?17:36??threedbmp\res\Toolbar.bmp
?????文件???????1100??2004-01-05?21:21??threedbmp\resource.h
?????文件???????2526??2003-11-01?10:30??threedbmp\SelectColorDlg.cpp
?????文件???????1590??2003-10-31?22:33??threedbmp\SelectColorDlg.h
?????文件????????209??2003-10-31?17:36??threedbmp\StdAfx.cpp
?????文件???????1118??2004-01-05?21:00??threedbmp\StdAfx.h
?????文件??????49152??2004-01-06?08:47??threedbmp\ThreeDBMP.exe
?????文件??????11656??2002-12-04?20:58??threedbmp\Urlli
?????文件???????2848??2002-12-04?20:57??threedbmp\Urlli
............此處省略5個文件信息
- 上一篇:手勢控制音樂播放器 源碼
- 下一篇:ieee9_3機9節點系統
評論
共有 條評論