提交 f0ee94b0 编写于 作者: P pssea

Description:fix snapshot view issue

IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I42GZ2
Feature or Bugfix: Feature
Binary Source:No
Signed-off-by: Nlizhiqi <lizhiqi1@huawei.com>
上级 b7ad581f
...@@ -45,7 +45,7 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info) ...@@ -45,7 +45,7 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info)
} }
uint16_t screenWidth = BaseGfxEngine::GetInstance()->GetScreenWidth(); uint16_t screenWidth = BaseGfxEngine::GetInstance()->GetScreenWidth();
uint16_t screenHeight = BaseGfxEngine::GetInstance()->GetScreenHeight(); 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.dataSize = screenWidth * screenHeight * DrawUtils::GetByteSizeByColorMode(info.header.colorMode);
info.data = reinterpret_cast<uint8_t*>(ImageCacheMalloc(info)); info.data = reinterpret_cast<uint8_t*>(ImageCacheMalloc(info));
if (info.data == nullptr) { if (info.data == nullptr) {
...@@ -56,11 +56,21 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info) ...@@ -56,11 +56,21 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info)
info.header.reserved = 0; info.header.reserved = 0;
info.header.compressMode = 0; info.header.compressMode = 0;
if (memcpy_s(static_cast<void *>(const_cast<uint8_t *>(info.data)), info.dataSize, Rect screenRect = {0, 0, static_cast<int16_t>(screenWidth - 1), static_cast<int16_t>(screenHeight - 1)};
bufferInfo->virAddr, info.dataSize) != EOK) { Point dstPos = {0, 0};
ImageCacheFree(info); BlendOption blendOption;
return false; blendOption.opacity = OPA_OPAQUE;
}
BufferInfo dstBufferInfo;
dstBufferInfo.rect = screenRect;
dstBufferInfo.mode = ARGB8888;
dstBufferInfo.color = 0x44;
dstBufferInfo.phyAddr = dstBufferInfo.virAddr = static_cast<void*>(const_cast<uint8_t*>(info.data));
dstBufferInfo.stride = screenWidth * 4; // 4: bpp
dstBufferInfo.width = screenWidth;
dstBufferInfo.height = screenHeight;
BaseGfxEngine::GetInstance()->Blit(dstBufferInfo, dstPos, *bufferInfo, screenRect, blendOption);
return true; return true;
} }
......
...@@ -917,7 +917,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap) ...@@ -917,7 +917,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap)
mask.Intersect(mask, screenRect); mask.Intersect(mask, screenRect);
uint16_t bufferWidth = static_cast<uint16_t>(mask.GetWidth()); uint16_t bufferWidth = static_cast<uint16_t>(mask.GetWidth());
uint16_t bufferHeight = static_cast<uint16_t>(mask.GetHeight()); uint16_t bufferHeight = static_cast<uint16_t>(mask.GetHeight());
bitmap.header.colorMode = bufferInfo->mode; bitmap.header.colorMode = ARGB8888;
bitmap.dataSize = bufferWidth * bufferHeight * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode); bitmap.dataSize = bufferWidth * bufferHeight * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode);
bitmap.header.width = bufferWidth; bitmap.header.width = bufferWidth;
bitmap.header.height = bufferHeight; bitmap.header.height = bufferHeight;
...@@ -937,7 +937,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap) ...@@ -937,7 +937,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap)
newBufferInfo.rect = mask; newBufferInfo.rect = mask;
newBufferInfo.width = bufferWidth; newBufferInfo.width = bufferWidth;
newBufferInfo.height = bufferHeight; newBufferInfo.height = bufferHeight;
newBufferInfo.mode = bufferInfo->mode; newBufferInfo.mode = ARGB8888;
newBufferInfo.stride = bufferWidth * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode); newBufferInfo.stride = bufferWidth * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode);
RootView::GetInstance()->SaveDrawContext(); RootView::GetInstance()->SaveDrawContext();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册