在黑莓中通过后台线程在 UI 上显示图像

发布于 2025-01-03 04:44:47 字数 624 浏览 4 评论 0原文

我正在寻找一种从后台线程在用户界面上显示图像的方法。该后台线程接收字节数组形式的流图像。我需要在我的用户界面上显示它 有人可以帮忙吗?

我已经尝试从后台线程访问位图字段,但没有任何反应,

谢谢

        bmp = Bitmap.createBitmapFromBytes(jpegBytes, 0, jpegBytes.length, 1);


        final Bitmap bit = bmp;
        final byte [] jp = jpegBytes;
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() 
            {                   
                camView.jpegBytes = jp;
                System.out.println(bit);
                camView.bmpStream.setBitmap(bit);
                //camView.bmpStream.
            }
        });

I am looking for a way to display images on my UI from a background thread. This background thread recieves streaming images in the form of byte array. I need to diplay it on my UI
Can anyone help with this please?

I already tried accessing the bitmap field from the background thread but nothing happens

Thanks

        bmp = Bitmap.createBitmapFromBytes(jpegBytes, 0, jpegBytes.length, 1);


        final Bitmap bit = bmp;
        final byte [] jp = jpegBytes;
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() 
            {                   
                camView.jpegBytes = jp;
                System.out.println(bit);
                camView.bmpStream.setBitmap(bit);
                //camView.bmpStream.
            }
        });

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

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

发布评论

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

评论(2

浪漫之都 2025-01-10 04:44:47

如果您需要更改主屏幕,意味着如果您需要从后台线程向主屏幕添加字段,您需要调用

invalidate();

方法来重新绘制屏幕,​​否则屏幕

Ex 中不会发生任何更改:

 UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() 
            {                   
                camView.jpegBytes = jp;
                System.out.println(bit);
                camView.bmpStream.setBitmap(bit);
                 invalidate();
                //camView.bmpStream.
            }
    });

If you need to change the Main Screen means if you need to add field to Main Screen from the Background thread you need to call

invalidate();

method to repaint the screen otherwise no change will place in Screen

Ex:

 UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() 
            {                   
                camView.jpegBytes = jp;
                System.out.println(bit);
                camView.bmpStream.setBitmap(bit);
                 invalidate();
                //camView.bmpStream.
            }
    });
兲鉂ぱ嘚淚 2025-01-10 04:44:47

嘿伙计们,我设法找到了我在使用对父类的引用时遇到的问题。如果您有对主类的引用,我在问题中发布的上述代码将非常有效。

Hey guys I managed to find the problem I had an issue with the used of references to my parent class. the above code I have posted in the question works perfect if you have a reference to the main class.

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