//头文件还缺些,自己加下吧
#include <utils/Log.h>
static const char DumpPath[] = "/.../.../...";
//设置编译所依赖的动态库
LOCAL_SHARED_LIBRARIES += liblog
//pData:首地址
//pFileName:文件路径
//pSubPath:子路径,可以填"",代表路径默认是DumpPath
//len:写入文件的长度,img宽x高
void WriteFile(
unsigned char* pData,
const char* pFileName,
const char* pSubPath,
int len)
{
FILE *pFile = NULL;
char finalePath[256];
MyJoin(DumpPath, pSubPath, finalePath);
// Ensure the finalePath ends with a path separator
if (finalePath[strlen(finalePath) - 1] != '/')
{
strcat(finalePath, "/");
}
mkdir(finalePath, 0777);
char pFilePath[256];
MyJoin(finalePath, pFileName, pFilePath);
pFile = fopen(pFilePath, "ab+");
if (NULL != pFile)
{
fwrite(pData, len, 1, pFile);
fclose(pFile);
}
else
{
ALOGE("open file: %s Failed", pFilePath);
}
}
//字符串拼接
void MyJoin(
const char *pString1,
const char *pString2,
char *pMyJoinResult)
{
strcpy(pMyJoinResult, pString1);
strcat(pMyJoinResult, "/");
strcat(pMyJoinResult, pString2);
}
//使用:
char pFileName[100];
std::sprintf(pFileName,
"muDump_wxh_%dx%d_img.raw",
myImg.size.width,
myImg.size.height);
WriteFile((uint8_t*)myImg.pVirtualAddr,
(const char*)pFileName,
"",
myImg.bufferSize);
[android camera raw图dump]
于 2024-07-09 11:42:04 首次发布