diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index 9d9795a6..4fb383aa 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -33,55 +33,6 @@ #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(yPlane + i * yStride), width); - } - - // 写入 U 分量(逐行复制,处理 Stride) - for (int i = 0; i < height / 2; i++) { - file.write(reinterpret_cast(uPlane + i * uStride), width / 2); - } - - // 写入 V 分量(逐行复制,处理 Stride) - for (int i = 0; i < height / 2; i++) { - file.write(reinterpret_cast(vPlane + i * vStride), width / 2); - } - // 关闭文件 - file.close(); -} - - #ifdef _DEBUG void Auto_AImage_delete(AImage* image) {