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();
                                    }
                                });

  • 相关阅读:
    阿里云“网红"运维工程师白金:做一个平凡的圆梦人
    3235 战争
    1291 火车线路(区间修改,区间最值)
    P3183 [HAOI2016]食物链
    P1189 SEARCH(逃跑的拉尔夫)
    P1794 装备运输_NOI导刊2010提高(04)
    P2347 砝码称重
    P1332 血色先锋队
    P1772 [ZJOI2006]物流运输
    P1038 神经网络
  • 原文地址:https://www.cnblogs.com/xushihai/p/4206631.html
Copyright © 2011-2022 走看看