修复编译错误

nx2024
Matthew 2 months ago
parent 8f6c7881e8
commit 9680cd7157

@ -33,55 +33,6 @@
#include "mtk_metadata_tag.h" #include "mtk_metadata_tag.h"
void saveYuvToFile(AImage* image, const std::string& filePath) {
int32_t width, height;
AImage_getWidth(image, &width);
AImage_getHeight(image, &height);
// 获取 YUV 数据
uint8_t* yPlane = nullptr;
uint8_t* uPlane = nullptr;
uint8_t* vPlane = nullptr;
int yLength, uLength, vLength;
AImage_getPlaneData(image, 0, &yPlane, &yLength); // Y 分量
AImage_getPlaneData(image, 1, &uPlane, &uLength); // U 分量
AImage_getPlaneData(image, 2, &vPlane, &vLength); // V 分量
int32_t yStride, uStride, vStride;
AImage_getPlaneRowStride(image, 0, &yStride); // Y 分量的 Stride
AImage_getPlaneRowStride(image, 1, &uStride); // U 分量的 Stride
AImage_getPlaneRowStride(image, 2, &vStride); // V 分量的 Stride
// 打开文件
std::ofstream file(filePath, std::ios::binary);
if (!file.is_open()) {
// 文件打开失败
return;
}
// 写入 Y 分量(逐行复制,处理 Stride
for (int i = 0; i < height; i++) {
file.write(reinterpret_cast<const char*>(yPlane + i * yStride), width);
}
// 写入 U 分量(逐行复制,处理 Stride
for (int i = 0; i < height / 2; i++) {
file.write(reinterpret_cast<const char*>(uPlane + i * uStride), width / 2);
}
// 写入 V 分量(逐行复制,处理 Stride
for (int i = 0; i < height / 2; i++) {
file.write(reinterpret_cast<const char*>(vPlane + i * vStride), width / 2);
}
// 关闭文件
file.close();
}
#ifdef _DEBUG #ifdef _DEBUG
void Auto_AImage_delete(AImage* image) void Auto_AImage_delete(AImage* image)
{ {

Loading…
Cancel
Save