From cf00a553b399247ef94b8280866365a25b599aa6 Mon Sep 17 00:00:00 2001 From: pssea Date: Mon, 26 Jul 2021 17:37:38 +0800 Subject: [PATCH] fixed f0ee94b from https://gitee.com/openharmony/graphic_ui/pulls/308 Description:fix snapshot view issue IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I42GZ2 Feature or Bugfix: Feature Binary Source:No Signed-off-by: lizhiqi --- frameworks/common/screen.cpp | 22 ++++++++++++++++------ frameworks/components/ui_view.cpp | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/frameworks/common/screen.cpp b/frameworks/common/screen.cpp index d43474a..fef9951 100755 --- a/frameworks/common/screen.cpp +++ b/frameworks/common/screen.cpp @@ -45,7 +45,7 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info) } uint16_t screenWidth = BaseGfxEngine::GetInstance()->GetScreenWidth(); uint16_t screenHeight = BaseGfxEngine::GetInstance()->GetScreenHeight(); - info.header.colorMode = bufferInfo->mode; + info.header.colorMode = ARGB8888; info.dataSize = screenWidth * screenHeight * DrawUtils::GetByteSizeByColorMode(info.header.colorMode); info.data = reinterpret_cast(ImageCacheMalloc(info)); if (info.data == nullptr) { @@ -56,11 +56,21 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info) info.header.reserved = 0; info.header.compressMode = 0; - if (memcpy_s(static_cast(const_cast(info.data)), info.dataSize, - bufferInfo->virAddr, info.dataSize) != EOK) { - ImageCacheFree(info); - return false; - } + Rect screenRect = {0, 0, static_cast(screenWidth - 1), static_cast(screenHeight - 1)}; + Point dstPos = {0, 0}; + BlendOption blendOption; + blendOption.opacity = OPA_OPAQUE; + + BufferInfo dstBufferInfo; + dstBufferInfo.rect = screenRect; + dstBufferInfo.mode = ARGB8888; + dstBufferInfo.color = 0x44; + dstBufferInfo.phyAddr = dstBufferInfo.virAddr = static_cast(const_cast(info.data)); + dstBufferInfo.stride = screenWidth * 4; // 4: bpp + dstBufferInfo.width = screenWidth; + dstBufferInfo.height = screenHeight; + + BaseGfxEngine::GetInstance()->Blit(dstBufferInfo, dstPos, *bufferInfo, screenRect, blendOption); return true; } diff --git a/frameworks/components/ui_view.cpp b/frameworks/components/ui_view.cpp index 957741c..5cbfed0 100755 --- a/frameworks/components/ui_view.cpp +++ b/frameworks/components/ui_view.cpp @@ -917,7 +917,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap) mask.Intersect(mask, screenRect); uint16_t bufferWidth = static_cast(mask.GetWidth()); uint16_t bufferHeight = static_cast(mask.GetHeight()); - bitmap.header.colorMode = bufferInfo->mode; + bitmap.header.colorMode = ARGB8888; bitmap.dataSize = bufferWidth * bufferHeight * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode); bitmap.header.width = bufferWidth; bitmap.header.height = bufferHeight; @@ -937,7 +937,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap) newBufferInfo.rect = mask; newBufferInfo.width = bufferWidth; newBufferInfo.height = bufferHeight; - newBufferInfo.mode = bufferInfo->mode; + newBufferInfo.mode = ARGB8888; newBufferInfo.stride = bufferWidth * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode); RootView::GetInstance()->SaveDrawContext(); -- GitLab