From 9680cd71577ba10e7ed2d527d91ab99a2eab5d30 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 17 Apr 2025 17:53:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/camera2/ndkcamera.cpp | 49 -------------------------- 1 file changed, 49 deletions(-) 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) {