zoukankan      html  css  js  c++  java
  • AndEngine之ScreenCapture

    AndEngine引擎提供了一个截图的类ScreenCapture

    这个类的用法:ScreenCapture  cap= new ScreenCapture();无参构造函数

    然后添加到场景中,如果不添加到场景中就截不到任何数据

    她有两个主要方法

    capture(final int pCaptureWidth, final int pCaptureHeight, final String pFilePath, final IScreenCaptureCallback pScreenCaptureCallback)

    和 capture(final int pCaptureX, final int pCaptureY, final int pCaptureWidth, final int pCaptureHeight, final String pFilePath, final IScreenCaptureCallback pScreencaptureCallback)

    pScreenCaptureCallback回调接口是当截图成功或失败后调用的 

    用的是out = new FileOutputStream(pFilePath);
             pBitmap.compress(CompressFormat.PNG, 100, out);

    还有就是AndEngine的***Activity有个方法runrunOnUiThread(runnable)能够在非UI线程中做一些UI操作,例如非UI线程不可以使用Toast,

    但是runrunOnUiThread方法里面就可以使用

    例如:

    CaptureSampleActivity.this.runOnUiThread(new Runnable() {
                                   
                                    @Override
                                    public void run() {
                                        Toast.makeText(getApplication(), "截图成功", Toast.LENGTH_LONG).show();
                                    }
                                });

  • 相关阅读:
    F
    E
    网上见到一同行发的隐私政策 备以后用
    Cannot connect to the Docker daemon. Is the docker daemon running on this host?
    mark
    转 随机数问题
    随机不同的数
    转 基于Quick-cocos2dx 2.2.3 的动态更新实现完整篇。(打包,服务器接口,模块自更新
    字符串
    关于cmbiling.jar cocos2dx的问题
  • 原文地址:https://www.cnblogs.com/xushihai/p/4206631.html
Copyright © 2011-2022 走看看