当屏幕不在显示堆栈上时,如何截取屏幕截图?黑莓

发布于 2025-01-06 04:48:19 字数 341 浏览 2 评论 0原文

我想要将屏幕从 my_screen1 转换到 my_screen2。想法是截取两个屏幕的屏幕截图,并使用动画从 1 过渡到 2。然后将 my_screen2 推送到显示堆栈上。但是,在将屏幕 my_screen2 推入显示堆栈之前,我可以截取它吗? 代码:

 Display.screenshot(bitmap);

给出已经显示的屏幕截图。有类似的东西吗:

 my_screen2.screenshot(bitmap);

请问有示例代码吗?多谢!

I want to make screen transition from my_screen1 to my_screen2. Idea is to take screenshot of both screens, and with animation to transit from 1 to 2. And then to push my_screen2 on display stack. But can I take screenshot of screen my_screen2 before I push it on display stack?
the code:

 Display.screenshot(bitmap);

gives screenshot of screen which is already on display. Is there something like:

 my_screen2.screenshot(bitmap);

Any example code please? Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的他你的她 2025-01-13 04:48:19

您无法对不在显示堆栈上或位于特定屏幕下方的屏幕进行屏幕截图。文档说 Display.screenshot() 获取整个屏幕的屏幕截图并将其保存到位图中。

如果您想要从一个屏幕过渡动画屏幕到另一个屏幕时,您可以执行以下操作。

UiEngineInstance engine = Ui.getUiEngineInstance();

                    TransitionContext transitionContextPush = new TransitionContext(
                            TransitionContext.TRANSITION_SLIDE);
                    transitionContextPush.setIntAttribute(
                            TransitionContext.ATTR_DURATION, 150);
                    transitionContextPush.setIntAttribute(
                            TransitionContext.ATTR_DIRECTION,
                            TransitionContext.DIRECTION_LEFT);

                    TransitionContext transitionContextPop = new TransitionContext(
                            TransitionContext.TRANSITION_SLIDE);
                    transitionContextPop.setIntAttribute(
                            TransitionContext.ATTR_DURATION, 150);
                    transitionContextPop.setIntAttribute(
                            TransitionContext.ATTR_DIRECTION,
                            TransitionContext.DIRECTION_RIGHT);
                    transitionContextPop.setIntAttribute(
                            TransitionContext.ATTR_KIND,
                            TransitionContext.KIND_OUT);

                    engine.setTransition(null, thisScreen,
                            UiEngineInstance.TRIGGER_PUSH,
                            transitionContextPush);
                    engine.setTransition(thisScreen, null,
                            UiEngineInstance.TRIGGER_POP,
                            transitionContextPop);
                }
                UiApplication.getUiApplication().pushScreen(thisScreen);

You cannot take screenshot of a screen which is not on the display stack ,or which is below a particular screen. The docs say that Display.screenshot() Takes a screenshot of the entire screen and saves it into a Bitmap.

If you want to have a screen transition animation to go from one screen to another, you can do the following.

UiEngineInstance engine = Ui.getUiEngineInstance();

                    TransitionContext transitionContextPush = new TransitionContext(
                            TransitionContext.TRANSITION_SLIDE);
                    transitionContextPush.setIntAttribute(
                            TransitionContext.ATTR_DURATION, 150);
                    transitionContextPush.setIntAttribute(
                            TransitionContext.ATTR_DIRECTION,
                            TransitionContext.DIRECTION_LEFT);

                    TransitionContext transitionContextPop = new TransitionContext(
                            TransitionContext.TRANSITION_SLIDE);
                    transitionContextPop.setIntAttribute(
                            TransitionContext.ATTR_DURATION, 150);
                    transitionContextPop.setIntAttribute(
                            TransitionContext.ATTR_DIRECTION,
                            TransitionContext.DIRECTION_RIGHT);
                    transitionContextPop.setIntAttribute(
                            TransitionContext.ATTR_KIND,
                            TransitionContext.KIND_OUT);

                    engine.setTransition(null, thisScreen,
                            UiEngineInstance.TRIGGER_PUSH,
                            transitionContextPush);
                    engine.setTransition(thisScreen, null,
                            UiEngineInstance.TRIGGER_POP,
                            transitionContextPop);
                }
                UiApplication.getUiApplication().pushScreen(thisScreen);

请参阅 rahul_narkhede 提供的有关 OS5 之前的滑动屏幕转换的解决方案,我过去曾成功使用过它。

http://supportforums.blackberry .com/t5/Java-Development/Animated-Screen-transitions/td-p/162521/page/6

See this solution by rahul_narkhede for pre-OS5 Sliding Screen Transitions, I have used it successfully in the past.

http://supportforums.blackberry.com/t5/Java-Development/Animated-Screen-transitions/td-p/162521/page/6

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文