From 787843ecc4625ab763fcd51bcd0ac76124d7a38a Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 3 Jan 2022 00:33:59 +0800 Subject: [PATCH] =?UTF-8?q?feat.=E6=94=AF=E6=8C=81=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8=E7=9A=84gzip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/config.json | 24 +++++++++++++++--------- src/MeoAssistant/Controller.cpp | 7 ++++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/resource/config.json b/resource/config.json index b2b7a48f5b..ca9b20bc55 100644 --- a/resource/config.json +++ b/resource/config.json @@ -40,7 +40,8 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p", + "screencap": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", + "screencapGzip": true, "release": "[Adb] kill-server" } }, @@ -61,7 +62,7 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] shell screencap | gzip -1", + "screencap": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapGzip": true, "release": "[Adb] kill-server" } @@ -83,7 +84,8 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p", + "screencap": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", + "screencapGzip": true, "release": "[Adb] kill-server" } }, @@ -105,7 +107,8 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] shell screencap -p", + "screencap": "[Adb] -s [Address] shell \"screencap | gzip -1\"", + "screencapGzip": true, "release": "[Adb] kill-server" } }, @@ -127,7 +130,8 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p", + "screencap": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", + "screencapGzip": true, "release": "[Adb] kill-server" } }, @@ -148,7 +152,8 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init=", "displayFormat": " init=%dx%d", - "screencap": "[Adb] -s [Address] shell screencap -p", + "screencap": "[Adb] -s [Address] shell \"screencap | gzip -1\"", + "screencapGzip": true, "release": "[Adb] kill-server" } }, @@ -167,9 +172,10 @@ "connect": "[Adb] connect [Address]", "click": "[Adb] -s [Address] shell input tap [x] [y]", "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", - "display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '", - "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p", + "display": "[Adb] -s [Address] shell dumpsys window displays | grep init=", + "displayFormat": " init=%dx%d", + "screencap": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", + "screencapGzip": true, "release": "[Adb] kill-server" } } diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index cddc0952c3..0ccbe99d83 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -578,12 +578,13 @@ bool asst::Controller::screencap() std::function&)> decode_func = nullptr; if (adb.screencap_gzip) { decode_func = [&](const std::vector& data) -> bool { - auto dst = gzip::decompress(data.data(), data.size()); - if (dst.empty()) { + auto unzip_data = gzip::decompress(data.data(), data.size()); + Log.trace("unzip data size:", unzip_data.size()); + if (unzip_data.empty()) { return false; } constexpr static int BmpHeaderSize = 12; - m_cache_image = cv::Mat(adb.display_height, adb.display_width, CV_8UC4, dst.data() + BmpHeaderSize); + m_cache_image = cv::Mat(adb.display_height, adb.display_width, CV_8UC4, unzip_data.data() + BmpHeaderSize); cv::cvtColor(m_cache_image, m_cache_image, cv::COLOR_RGB2BGR); return !m_cache_image.empty(); };