VC代码为:
CString path="c:\\1.jpg";
CFile myFile;
byte* data;
if(myFile.Open(path, CFile::modeRead | CFile::typeBinary))
{
UINT filelen=myFile.GetLength();
data = new byte[filelen];
_variant_t outData;
UINT dw=myFile.Read(data,filelen);
if (dw==filelen)
{

theApp.buffer->ByteToVariant(data,filelen,&outData);
myFile.Close();
int x0,x1,y1,y0;
BOOL ok1=theApp.face->FindFace(outData,&x0,&x1,&y0,&y1);
}
}
其中 ByteToVariant 函数为:void CImageBuffer::ByteToVariant(byte *bData, long bSize, VARIANT *pOutAarry)
{
SAFEARRAY* psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements =bSize;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);

for (long i = 0; i <bSize; i++)
SafeArrayPutElement (psa, &i,bData++);
pOutAarry->vt = VT_ARRAY | VT_UI1;
pOutAarry->parray = psa;}