feat.支持更多模拟器的gzip

This commit is contained in:
MistEO
2022-01-03 00:33:59 +08:00
parent c9f1de8811
commit 787843ecc4
2 changed files with 19 additions and 12 deletions

View File

@@ -578,12 +578,13 @@ bool asst::Controller::screencap()
std::function<bool(const std::vector<uchar>&)> decode_func = nullptr;
if (adb.screencap_gzip) {
decode_func = [&](const std::vector<uchar>& 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();
};