好友
阅读权限 10
听众
最后登录 1970-1-1
原帖地址:VC++ QQ桌球外挂源码问题(编译通过,运行程序崩溃)急急急
http://www.unpack.cn/thread-85245-1-1.html
让大家也看看哪里的问题:
前天朋友给了一个QQ桌球外挂程序源码,但是不知道这程序怎么的,编译都通过了,
但是运行的时候崩溃了,在灰度化的时候正常,但是在二值化时崩溃了,
调试了很久都没找到原因,请给位朋友看看,本人菜鸟一个,忘大牛多多
帮忙,再次谢谢大家了
下面QQ桌球外挂程序源码的链接:
http://pan.baidu.com/share/link?shareid=111425&uk=2936981401
程序出错地方:
void changefile2(TCHAR *NAME1,TCHAR *NAME2,TCHAR *NAME3)
{
BITMAPFILEHEADER bitHead;
BITMAPINFOHEADER bitInfoHead;
FILE* pfile = NULL;
WORD fileType;
pfile = fopen(NAME1,"rb");//打开文件
if(pfile!=NULL)
{
fread(&fileType,1,sizeof(WORD),pfile);
fread(&bitHead,1,sizeof(tagBITMAPFILEHEADER),pfile);
//读取位图信息头信息
fread(&bitInfoHead,1,sizeof(BITMAPINFOHEADER),pfile);
}
tagRGBQUAD *pRgb ;
//读取调色盘结信息
long nPlantNum = long(pow(2,double(bitInfoHead.biBitCount))); // Mix color Plant Number;
pRgb=(tagRGBQUAD *)malloc(nPlantNum*sizeof(tagRGBQUAD));
memset(pRgb,0,nPlantNum*sizeof(tagRGBQUAD));
int num = fread(pRgb,4,nPlantNum,pfile);
int width = bitInfoHead.biWidth;
int height = bitInfoHead.biHeight;
//分配内存空间把源图存入内存
BYTE *pColorData=(BYTE *)malloc(height*width); //ad
memset(pColorData,0,height*width);//ad
long nData = height*width; //ad
//把位图数据信息读到数组里
fread(pColorData,1,nData,pfile);
//将位图数据转化为RGB数据
tagRGBQUAD* dataOfBmp;
dataOfBmp = (tagRGBQUAD *)malloc(width*height*sizeof(tagRGBQUAD));//用于保存各像素对应的RGB数据
memset(dataOfBmp,0,width*height*sizeof(tagRGBQUAD));
int k;
int index = 0;
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
{
BYTE mixIndex= 0;
k = i*width + j; //ad
mixIndex = pColorData[k];
dataOfBmp[index].rgbRed = pRgb[mixIndex].rgbRed;
dataOfBmp[index].rgbGreen = pRgb[mixIndex].rgbGreen;
dataOfBmp[index].rgbBlue = pRgb[mixIndex].rgbBlue;
dataOfBmp[index].rgbReserved = pRgb[mixIndex].rgbReserved;
index++;
}
sobelEdgeDetectV(pColorData,width,height);//sobel
FILE *pwrite=NULL;//写sobel之后的图像
pwrite=fopen(NAME2,"wb");
fwrite(&fileType,sizeof(WORD),1,pwrite);
fwrite(&bitHead,sizeof(tagBITMAPFILEHEADER),1,pwrite);
fwrite(&bitInfoHead,sizeof(BITMAPINFOHEADER),1,pwrite);
fwrite(pRgb,4,nPlantNum,pwrite);
fwrite(pColorData,1,nData,pwrite);
fclose(pwrite);
adaptiveB(pColorData,width,height);//自适应
FILE *pwrite1=NULL;//写自适应二值化之后的图像
pwrite1=fopen(NAME3,"wb");
fwrite(&fileType,sizeof(WORD),1,pwrite1);
fwrite(&bitHead,sizeof(tagBITMAPFILEHEADER),1,pwrite1);
fwrite(&bitInfoHead,sizeof(BITMAPINFOHEADER),1,pwrite1);
fwrite(pRgb,4,nPlantNum,pwrite1);
fwrite(pColorData,1,nData,pwrite1);
fclose(pwrite1);
fclose(pfile);
if (bitInfoHead.biBitCount<24)
{
free(pRgb);
}
free(dataOfBmp);
free(pColorData);
}