未验证 提交 885b6f72 编写于 作者: O openharmony_ci 提交者: Gitee

!810 新增截屏模式

Merge pull request !810 from Zhouyj/xrgb1107
...@@ -1273,7 +1273,7 @@ uint8_t UIView::GetMixOpaScale() const ...@@ -1273,7 +1273,7 @@ uint8_t UIView::GetMixOpaScale() const
return opaMix; return opaMix;
} }
bool UIView::GetBitmap(ImageInfo& imageInfo) bool UIView::GetBitmap(ImageInfo& imageInfo, ColorMode colorMode)
{ {
UIView* tempRenderSibling = nextRenderSibling_; UIView* tempRenderSibling = nextRenderSibling_;
nextRenderSibling_ = nullptr; nextRenderSibling_ = nullptr;
...@@ -1284,7 +1284,7 @@ bool UIView::GetBitmap(ImageInfo& imageInfo) ...@@ -1284,7 +1284,7 @@ bool UIView::GetBitmap(ImageInfo& imageInfo)
rect_.SetPosition(0, 0); rect_.SetPosition(0, 0);
Rect mask = GetRect(); Rect mask = GetRect();
BufferInfo bufInfo{mask, 0, nullptr, nullptr, 0, 0, ARGB8888, 0}; BufferInfo bufInfo{mask, 0, nullptr, nullptr, 0, 0, colorMode, 0};
bufInfo.width = mask.GetWidth(); bufInfo.width = mask.GetWidth();
bufInfo.height = mask.GetHeight(); bufInfo.height = mask.GetHeight();
bufInfo.stride = bufInfo.width * DrawUtils::GetByteSizeByColorMode(bufInfo.mode); bufInfo.stride = bufInfo.width * DrawUtils::GetByteSizeByColorMode(bufInfo.mode);
......
...@@ -49,7 +49,7 @@ namespace OHOS { ...@@ -49,7 +49,7 @@ namespace OHOS {
/* cover mode, src alpha is 255 */ /* cover mode, src alpha is 255 */
#define COLOR_FILL_COVER(d, dm, r2, g2, b2, sm) \ #define COLOR_FILL_COVER(d, dm, r2, g2, b2, sm) \
if ((dm) == ARGB8888) { \ if ((dm) == ARGB8888 || (dm) == XRGB8888) { \
reinterpret_cast<Color32*>(d)->alpha = OPA_OPAQUE; \ reinterpret_cast<Color32*>(d)->alpha = OPA_OPAQUE; \
if (sm == RGB565) { \ if (sm == RGB565) { \
reinterpret_cast<Color32*>(d)->red = (r2) << 3; \ reinterpret_cast<Color32*>(d)->red = (r2) << 3; \
...@@ -71,7 +71,7 @@ namespace OHOS { ...@@ -71,7 +71,7 @@ namespace OHOS {
reinterpret_cast<Color24*>(d)->blue = (b2); \ reinterpret_cast<Color24*>(d)->blue = (b2); \
} \ } \
} else if ((dm) == RGB565) { \ } else if ((dm) == RGB565) { \
if ((sm) == ARGB8888 || (sm) == RGB888) { \ if ((sm) == ARGB8888 || (sm) == RGB888 || (sm) == XRGB8888) { \
reinterpret_cast<Color16*>(d)->red = (r2) >> 3; \ reinterpret_cast<Color16*>(d)->red = (r2) >> 3; \
reinterpret_cast<Color16*>(d)->green = (g2) >> 2; \ reinterpret_cast<Color16*>(d)->green = (g2) >> 2; \
reinterpret_cast<Color16*>(d)->blue = (b2) >> 3; \ reinterpret_cast<Color16*>(d)->blue = (b2) >> 3; \
...@@ -93,6 +93,12 @@ namespace OHOS { ...@@ -93,6 +93,12 @@ namespace OHOS {
(b1) = static_cast<uint8_t>((Alpha2 * (b2) + (1 - Alpha2) * Alpha1 * (b1)) / Alpha3); \ (b1) = static_cast<uint8_t>((Alpha2 * (b2) + (1 - Alpha2) * Alpha1 * (b1)) / Alpha3); \
(a1) = static_cast<uint8_t>(Alpha3 * OPA_OPAQUE) (a1) = static_cast<uint8_t>(Alpha3 * OPA_OPAQUE)
#define COLOR_BLEND_XRGB(r1, g1, b1, a1, r2, g2, b2, a2) \
(r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(b1) = (((b2) * (a2)) / OPA_OPAQUE) + (((b1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(a1) = static_cast<uint8_t>(OPA_OPAQUE)
#define COLOR_BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \ #define COLOR_BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \
(r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \ (r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \ (g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
...@@ -102,7 +108,7 @@ namespace OHOS { ...@@ -102,7 +108,7 @@ namespace OHOS {
#define COLOR_FILL_BLEND(d, dm, s, sm, a) \ #define COLOR_FILL_BLEND(d, dm, s, sm, a) \
if ((dm) == ARGB8888) { \ if ((dm) == ARGB8888) { \
Color32* p = reinterpret_cast<Color32*>(d); \ Color32* p = reinterpret_cast<Color32*>(d); \
if ((sm) == ARGB8888) { \ if ((sm) == ARGB8888 || (sm) == XRGB8888) { \
Color32* sTmp = reinterpret_cast<Color32*>(s); \ Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \ uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, alpha); \ COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, alpha); \
...@@ -114,9 +120,23 @@ namespace OHOS { ...@@ -114,9 +120,23 @@ namespace OHOS {
COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, (sTmp->red) << 3, (sTmp->green) << 2, \ COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, (sTmp->red) << 3, (sTmp->green) << 2, \
(sTmp->blue) << 3, a); \ (sTmp->blue) << 3, a); \
} \ } \
} else if ((dm) == XRGB8888) { \
Color32* p = reinterpret_cast<Color32*>(d); \
if ((sm) == ARGB8888 || (sm) == XRGB8888) { \
Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_XRGB(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, alpha); \
} else if ((sm) == RGB888) { \
Color24* sTmp = reinterpret_cast<Color24*>(s); \
COLOR_BLEND_XRGB(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, a); \
} else if ((sm) == RGB565) { \
Color16* sTmp = reinterpret_cast<Color16*>(s); \
COLOR_BLEND_XRGB(p->red, p->green, p->blue, p->alpha, (sTmp->red) << 3, (sTmp->green) << 2, \
(sTmp->blue) << 3, a); \
} \
} else if ((dm) == RGB888) { \ } else if ((dm) == RGB888) { \
Color24* p = reinterpret_cast<Color24*>(d); \ Color24* p = reinterpret_cast<Color24*>(d); \
if ((sm) == ARGB8888) { \ if ((sm) == ARGB8888 || (sm) == XRGB8888) { \
Color32* sTmp = reinterpret_cast<Color32*>(s); \ Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \ uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_RGB(p->red, p->green, p->blue, sTmp->red, sTmp->green, sTmp->blue, alpha); \ COLOR_BLEND_RGB(p->red, p->green, p->blue, sTmp->red, sTmp->green, sTmp->blue, alpha); \
...@@ -129,7 +149,7 @@ namespace OHOS { ...@@ -129,7 +149,7 @@ namespace OHOS {
} \ } \
} else if ((dm) == RGB565) { \ } else if ((dm) == RGB565) { \
Color16* p = reinterpret_cast<Color16*>(d); \ Color16* p = reinterpret_cast<Color16*>(d); \
if ((sm) == ARGB8888) { \ if ((sm) == ARGB8888 || (sm) == XRGB8888) { \
Color32* sTmp = reinterpret_cast<Color32*>(s); \ Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \ uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_RGB(p->red, p->green, p->blue, (sTmp->red) >> 3, (sTmp->green) >> 2, (sTmp->blue) >> 3, \ COLOR_BLEND_RGB(p->red, p->green, p->blue, (sTmp->red) >> 3, (sTmp->green) >> 2, (sTmp->blue) >> 3, \
...@@ -208,6 +228,7 @@ uint8_t DrawUtils::GetPxSizeByColorMode(uint8_t colorMode) ...@@ -208,6 +228,7 @@ uint8_t DrawUtils::GetPxSizeByColorMode(uint8_t colorMode)
case TSC6: case TSC6:
case TSC6A: case TSC6A:
case ARGB8888: case ARGB8888:
case XRGB8888:
return 32; // 32: 32 bit return 32; // 32: 32 bit
case RGB888: case RGB888:
return 24; // 24: 24 bit return 24; // 24: 24 bit
...@@ -236,6 +257,7 @@ uint8_t DrawUtils::GetByteSizeByColorMode(uint8_t colorMode) ...@@ -236,6 +257,7 @@ uint8_t DrawUtils::GetByteSizeByColorMode(uint8_t colorMode)
{ {
switch (colorMode) { switch (colorMode) {
case ARGB8888: case ARGB8888:
case XRGB8888:
return 4; // 4: 4 Byte return 4; // 4: 4 Byte
case RGB888: case RGB888:
return 3; // 3: 3 Byte return 3; // 3: 3 Byte
...@@ -494,6 +516,7 @@ void DrawUtils::DrawImage(BufferInfo& gfxDstBuffer, ...@@ -494,6 +516,7 @@ void DrawUtils::DrawImage(BufferInfo& gfxDstBuffer,
Point dstPos = {maskedArea.GetLeft(), maskedArea.GetTop()}; Point dstPos = {maskedArea.GetLeft(), maskedArea.GetTop()};
BlendOption blendOption; BlendOption blendOption;
blendOption.opacity = opa; blendOption.opacity = opa;
blendOption.mode = BLEND_SRC_OVER;
BaseGfxEngine::GetInstance()->Blit(gfxDstBuffer, dstPos, src, maskedArea, blendOption); BaseGfxEngine::GetInstance()->Blit(gfxDstBuffer, dstPos, src, maskedArea, blendOption);
} }
...@@ -1673,6 +1696,15 @@ void DrawUtils::DrawTriangleTrueColorNearest(const TriangleScanInfo& in, const C ...@@ -1673,6 +1696,15 @@ void DrawUtils::DrawTriangleTrueColorNearest(const TriangleScanInfo& in, const C
} }
break; break;
} }
case XRGB8888: {
Color32 p32 = *(reinterpret_cast<Color32*>(&imgHead[px1]));
if ((in.opaScale == OPA_OPAQUE) && (p32.alpha == OPA_OPAQUE)) {
COLOR_FILL_COVER(screenBuffer, bufferMode, p32.red, p32.green, p32.blue, XRGB8888);
} else {
COLOR_FILL_BLEND(screenBuffer, bufferMode, &p32, XRGB8888, in.opaScale);
}
break;
}
default: default:
return; return;
} }
...@@ -1733,12 +1765,12 @@ void DrawUtils::DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const Triang ...@@ -1733,12 +1765,12 @@ void DrawUtils::DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const Triang
uint8_t pixelSize; uint8_t pixelSize;
DrawTriangleTransformFuc fuc; DrawTriangleTransformFuc fuc;
bool isTrueColor = (part.info.header.colorMode == ARGB8888) || (part.info.header.colorMode == RGB888) || bool isTrueColor = (part.info.header.colorMode == ARGB8888) || (part.info.header.colorMode == RGB888) ||
(part.info.header.colorMode == RGB565); (part.info.header.colorMode == RGB565) || (part.info.header.colorMode == XRGB8888);
if (isTrueColor) { if (isTrueColor) {
pixelSize = part.info.pxSize >> SHIFT_3; pixelSize = part.info.pxSize >> SHIFT_3;
if (part.info.algorithm == TransformAlgorithm::NEAREST_NEIGHBOR) { if (part.info.algorithm == TransformAlgorithm::NEAREST_NEIGHBOR) {
fuc = DrawTriangleTrueColorNearest; fuc = DrawTriangleTrueColorNearest;
} else if (part.info.header.colorMode == ARGB8888) { } else if (part.info.header.colorMode == ARGB8888 || part.info.header.colorMode == XRGB8888) {
if (part.transMap.Is3DTransform()) { if (part.transMap.Is3DTransform()) {
fuc = Draw3DTriangleTrueColorBilinear8888; fuc = Draw3DTriangleTrueColorBilinear8888;
} else { } else {
......
...@@ -1497,11 +1497,12 @@ public: ...@@ -1497,11 +1497,12 @@ public:
/** /**
* @brief 获取当前视图的bitmap截图.请注意该接口会申请内存,请在需要释放时使用{@link ImageCacheFree()}接口. * @brief 获取当前视图的bitmap截图.请注意该接口会申请内存,请在需要释放时使用{@link ImageCacheFree()}接口.
* @param info bitmap存储对象,获取的截图将被存到该引用中. * @param info bitmap存储对象,获取的截图将被存到该引用中.
* @param colorMode 截图格式,默认状态下为带透明度的ARGB8888.
* @return bitmap是否获取成功. * @return bitmap是否获取成功.
* @since 5.0 * @since 5.0
* @version 3.0 * @version 3.0
*/ */
bool GetBitmap(ImageInfo& bitmap); bool GetBitmap(ImageInfo& bitmap, ColorMode colorMode = ARGB8888);
bool IsOnViewTree(); bool IsOnViewTree();
......
...@@ -47,7 +47,122 @@ public: ...@@ -47,7 +47,122 @@ public:
if (info_.data != nullptr) { if (info_.data != nullptr) {
ImageCacheFree(info_); ImageCacheFree(info_);
} }
view.GetBitmap(info_); view.GetBitmap(info_, ARGB8888);
img_->SetVisible(true);
img_->SetSrc(&info_);
img_->Invalidate();
return false;
}
private:
UIViewGroup* container_;
UIImageView* img_;
ImageInfo info_;
};
class ViewBitmapListener2 : public UIView::OnClickListener {
public:
ViewBitmapListener2(UIViewGroup* container, UIImageView* img) : container_(container), img_(img)
{
(void)memset_s(&info_, sizeof(ImageInfo), 0, sizeof(ImageInfo));
if ((img != nullptr) && (container != nullptr)) {
container->Add(img);
img->SetVisible(false);
}
}
virtual ~ViewBitmapListener2()
{
if (info_.data != nullptr) {
ImageCacheFree(info_);
}
}
bool OnClick(UIView& view, const ClickEvent& event) override
{
if (img_ == nullptr) {
return false;
}
if (info_.data != nullptr) {
ImageCacheFree(info_);
}
view.GetBitmap(info_, XRGB8888);
img_->SetVisible(true);
img_->SetSrc(&info_);
img_->Invalidate();
return false;
}
private:
UIViewGroup* container_;
UIImageView* img_;
ImageInfo info_;
};
class ViewBitmapListener3 : public UIView::OnClickListener {
public:
ViewBitmapListener3(UIViewGroup* container, UIImageView* img) : container_(container), img_(img)
{
(void)memset_s(&info_, sizeof(ImageInfo), 0, sizeof(ImageInfo));
if ((img != nullptr) && (container != nullptr)) {
container->Add(img);
img->SetVisible(false);
}
}
virtual ~ViewBitmapListener3()
{
if (info_.data != nullptr) {
ImageCacheFree(info_);
}
}
bool OnClick(UIView& view, const ClickEvent& event) override
{
if (img_ == nullptr) {
return false;
}
if (info_.data != nullptr) {
ImageCacheFree(info_);
}
view.GetBitmap(info_, RGB888);
img_->SetVisible(true);
img_->SetSrc(&info_);
img_->Invalidate();
return false;
}
private:
UIViewGroup* container_;
UIImageView* img_;
ImageInfo info_;
};
class ViewBitmapListener4 : public UIView::OnClickListener {
public:
ViewBitmapListener4(UIViewGroup* container, UIImageView* img) : container_(container), img_(img)
{
(void)memset_s(&info_, sizeof(ImageInfo), 0, sizeof(ImageInfo));
if ((img != nullptr) && (container != nullptr)) {
container->Add(img);
img->SetVisible(false);
}
}
virtual ~ViewBitmapListener4()
{
if (info_.data != nullptr) {
ImageCacheFree(info_);
}
}
bool OnClick(UIView& view, const ClickEvent& event) override
{
if (img_ == nullptr) {
return false;
}
if (info_.data != nullptr) {
ImageCacheFree(info_);
}
view.GetBitmap(info_, RGB565);
img_->SetVisible(true); img_->SetVisible(true);
img_->SetSrc(&info_); img_->SetSrc(&info_);
img_->Invalidate(); img_->Invalidate();
...@@ -105,11 +220,27 @@ void UITestViewBitmap::SetUp() ...@@ -105,11 +220,27 @@ void UITestViewBitmap::SetUp()
container_ = new UIScrollView(); container_ = new UIScrollView();
container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT); container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
container_->SetHorizontalScrollState(false); container_->SetHorizontalScrollState(false);
container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
} }
if (viewBitmap_ == nullptr) { if (viewBitmap_ == nullptr) {
viewBitmap_ = new UIImageView(); viewBitmap_ = new UIImageView();
// 500 : x pos of image; 50: y pos of image; 960 width of image; 480 : height of image. // 100 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap_->SetPosition(500, 50, 960, 480); viewBitmap_->SetPosition(100, 100, 960, 480);
}
if (viewBitmap2_ == nullptr) {
viewBitmap2_ = new UIImageView();
// 300 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap2_->SetPosition(300, 100, 960, 480);
}
if (viewBitmap3_ == nullptr) {
viewBitmap3_ = new UIImageView();
// 500 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap3_->SetPosition(500, 100, 960, 480);
}
if (viewBitmap4_ == nullptr) {
viewBitmap4_ = new UIImageView();
// 700 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap4_->SetPosition(700, 100, 960, 480);
} }
if (screenBitmap_ == nullptr) { if (screenBitmap_ == nullptr) {
screenBitmap_ = new UIImageView(); screenBitmap_ = new UIImageView();
...@@ -119,6 +250,15 @@ void UITestViewBitmap::SetUp() ...@@ -119,6 +250,15 @@ void UITestViewBitmap::SetUp()
if (viewBitmapListener_ == nullptr) { if (viewBitmapListener_ == nullptr) {
viewBitmapListener_ = new ViewBitmapListener(container_, viewBitmap_); viewBitmapListener_ = new ViewBitmapListener(container_, viewBitmap_);
} }
if (viewBitmapListener2_ == nullptr) {
viewBitmapListener2_ = new ViewBitmapListener2(container_, viewBitmap2_);
}
if (viewBitmapListener3_ == nullptr) {
viewBitmapListener3_ = new ViewBitmapListener3(container_, viewBitmap3_);
}
if (viewBitmapListener4_ == nullptr) {
viewBitmapListener4_ = new ViewBitmapListener4(container_, viewBitmap4_);
}
if (screenBitmapListener_ == nullptr) { if (screenBitmapListener_ == nullptr) {
screenBitmapListener_ = new ScreenBitmapListener(container_, screenBitmap_); screenBitmapListener_ = new ScreenBitmapListener(container_, screenBitmap_);
} }
...@@ -130,20 +270,37 @@ void UITestViewBitmap::TearDown() ...@@ -130,20 +270,37 @@ void UITestViewBitmap::TearDown()
delete viewBitmapListener_; delete viewBitmapListener_;
viewBitmapListener_ = nullptr; viewBitmapListener_ = nullptr;
} }
if (viewBitmapListener2_ != nullptr) {
delete viewBitmapListener2_;
viewBitmapListener2_ = nullptr;
}
if (viewBitmapListener3_ != nullptr) {
delete viewBitmapListener3_;
viewBitmapListener3_ = nullptr;
}
if (viewBitmapListener4_ != nullptr) {
delete viewBitmapListener4_;
viewBitmapListener4_ = nullptr;
}
if (screenBitmapListener_ != nullptr) { if (screenBitmapListener_ != nullptr) {
delete screenBitmapListener_; delete screenBitmapListener_;
screenBitmapListener_ = nullptr; screenBitmapListener_ = nullptr;
} }
DeleteChildren(container_); DeleteChildren(container_);
container_ = nullptr; container_ = nullptr;
viewBitmap_ = nullptr; viewBitmap_ = nullptr;
viewBitmap2_ = nullptr;
viewBitmap3_ = nullptr;
viewBitmap4_ = nullptr;
screenBitmap_ = nullptr; screenBitmap_ = nullptr;
} }
const UIView* UITestViewBitmap::GetTestView() const UIView* UITestViewBitmap::GetTestView()
{ {
UIKitBitmapTestGetViewBitmap001(); UIKitBitmapTestGetViewBitmap001();
UIKitBitmapTestGetViewBitmap002();
UIKitBitmapTestGetViewBitmap003();
UIKitBitmapTestGetViewBitmap004();
UIKitBitmapTestGetScreenBitmap001(); UIKitBitmapTestGetScreenBitmap001();
return container_; return container_;
} }
...@@ -154,7 +311,7 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001() ...@@ -154,7 +311,7 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001()
container_->Add(btn); container_->Add(btn);
// 100 : x pos of button; 50: y pos of button. // 100 : x pos of button; 50: y pos of button.
btn->SetPosition(100, 50, BUTTON_WIDHT3, BUTTON_HEIGHT3); btn->SetPosition(100, 50, BUTTON_WIDHT3, BUTTON_HEIGHT3);
btn->SetText("测试组件截屏"); btn->SetText("组件ARGB截屏");
btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE); btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
btn->SetOnClickListener(viewBitmapListener_); btn->SetOnClickListener(viewBitmapListener_);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED); btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
...@@ -163,7 +320,57 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001() ...@@ -163,7 +320,57 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001()
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED); btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED); btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE); btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
btn->SetViewId(UI_TEST_COMPONENT_SCREENSHOT); }
void UITestViewBitmap::UIKitBitmapTestGetViewBitmap002()
{
UILabelButton* btn = new UILabelButton();
container_->Add(btn);
// 300 : x pos of button; 50: y pos of button.
btn->SetPosition(300, 50, BUTTON_WIDHT3, BUTTON_HEIGHT3);
btn->SetText("组件XRGB截屏");
btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
btn->SetOnClickListener(viewBitmapListener2_);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
}
void UITestViewBitmap::UIKitBitmapTestGetViewBitmap003()
{
UILabelButton* btn = new UILabelButton();
container_->Add(btn);
// 500 : x pos of button; 50: y pos of button.
btn->SetPosition(500, 50, BUTTON_WIDHT3, BUTTON_HEIGHT3);
btn->SetText("组件RGB888截屏");
btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
btn->SetOnClickListener(viewBitmapListener3_);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
}
void UITestViewBitmap::UIKitBitmapTestGetViewBitmap004()
{
UILabelButton* btn = new UILabelButton();
container_->Add(btn);
// 700 : x pos of button; 50: y pos of button.
btn->SetPosition(700, 50, BUTTON_WIDHT3, BUTTON_HEIGHT3);
btn->SetText("组件RGB565截屏");
btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
btn->SetOnClickListener(viewBitmapListener4_);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
} }
void UITestViewBitmap::UIKitBitmapTestGetScreenBitmap001() void UITestViewBitmap::UIKitBitmapTestGetScreenBitmap001()
......
...@@ -32,12 +32,21 @@ public: ...@@ -32,12 +32,21 @@ public:
void TearDown() override; void TearDown() override;
const UIView* GetTestView() override; const UIView* GetTestView() override;
void UIKitBitmapTestGetViewBitmap001(); void UIKitBitmapTestGetViewBitmap001();
void UIKitBitmapTestGetViewBitmap002();
void UIKitBitmapTestGetViewBitmap003();
void UIKitBitmapTestGetViewBitmap004();
void UIKitBitmapTestGetScreenBitmap001(); void UIKitBitmapTestGetScreenBitmap001();
private: private:
UIScrollView* container_ = nullptr; UIScrollView* container_ = nullptr;
UIImageView* viewBitmap_ = nullptr; UIImageView* viewBitmap_ = nullptr;
UIImageView* viewBitmap2_ = nullptr;
UIImageView* viewBitmap3_ = nullptr;
UIImageView* viewBitmap4_ = nullptr;
UIImageView* screenBitmap_ = nullptr; UIImageView* screenBitmap_ = nullptr;
UIView::OnClickListener* viewBitmapListener_ = nullptr; UIView::OnClickListener* viewBitmapListener_ = nullptr;
UIView::OnClickListener* viewBitmapListener2_ = nullptr;
UIView::OnClickListener* viewBitmapListener3_ = nullptr;
UIView::OnClickListener* viewBitmapListener4_ = nullptr;
UIView::OnClickListener* screenBitmapListener_ = nullptr; UIView::OnClickListener* screenBitmapListener_ = nullptr;
}; };
} // namespace OHOS } // namespace OHOS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册