/*********************************************************************** Following fuction load .dt file sName, the file name pWidth, return the width of the image pHeight, return the height of the image return value: return a memory block contains the binary image data, with color(RGB,one byte each) of each pixel from left to right, bottom to top. For example, if the image is a 10*10 image, then the return value pRes points to a memory block of size 10*10*3, and pRes[0],pRes[1],pRes[2] are the R,G,B color of the first pixel of the image, valued from 0 to 255. If failed, return 0 NOTE: please add following include codes first #include #include #include ***********************************************************************/ GLubyte* LoadDtFile(char* sName, int* pWidth, int* pHeight) { FILE *pF; struct stat fileStat; int iLen; GLubyte* pCur=0; GLubyte* pData=0; if( (pF = fopen(sName, "r" )) == 0) return 0; stat(sName, &fileStat); pData = (GLubyte*)malloc(fileStat.st_size); if(pData==0) return 0; pCur = (GLubyte*)malloc(fileStat.st_size-8); if(pCur==0) { free(pData); return 0; } iLen=fread(pData, 1, fileStat.st_size, pF); fclose(pF); memcpy(pWidth, pData, 4); memcpy(pHeight,pData+4, 4); memcpy((void*)pCur, pData+8, fileStat.st_size-8); free(pData); return pCur; }