BOOL JPG2Bin(CString photoPath)
{
char szStr[256] = {0};
wcstombs(szStr, photoPath, 256);
const char *strPath = szStr;
if(!strPath)
{
return FALSE;
}
FILE *fp = fopen(strPath, "r+");
if(!fp)
{
return FALSE;
}
fseek(fp, 0L, SEEK_END);
int iFileSize = ftell(fp) * sizeof(char);
char *strTemp = new char[iFileSize + 1];
fseek(fp, 0L, SEEK_SET);
const int BLOCK = 512;
char fbuf[BLOCK]={0};
char *p = strTemp;
int re = 0;
int index = 0;
do
{
//p += index;
re = fread(p + index,sizeof(char),BLOCK,fp);
index += re;
} while (re > 0);
*(p + index) = '\0';
if (fp)
fclose(fp);
return TRUE;
}
//要注意strTemp的释放