// This handler callback is tied to the UI thread.
 public boolean handleMessage(Message msg) {
   switch (msg.what) {
     case MSG_GETVIEWIMAGE:
       {
         AsyncResult result = (AsyncResult) msg.obj;
         result.setResult(TiUIHelper.viewToBitmap(null, (View) result.getArg()));
         return true;
       }
   }
   return super.handleMessage(msg);
 }
  @Kroll.method
  public TiBlob getFilteredScreenshot(HashMap options) {
    if (options != null) {
      if (options.containsKey("callback")) {
        KrollFunction callback = (KrollFunction) options.get("callback");
        if (callback != null) {
          (new FilterScreenShotTask()).execute(options);
          return null;
        }
      }
    }

    //        View view = TiApplication.getAppCurrentActivity().getWindow()
    //                .getDecorView();
    View view =
        TiApplication.getAppCurrentActivity()
            .getWindow()
            .getDecorView()
            .findViewById(android.R.id.content);
    if (view == null) {
      return null;
    }

    Bitmap bitmap = null;
    try {
      if (TiApplication.isUIThread()) {
        bitmap = TiUIHelper.viewToBitmap(null, view);
      } else {
        bitmap =
            (Bitmap)
                TiMessenger.sendBlockingMainMessage(
                    getMainHandler().obtainMessage(MSG_GETVIEWIMAGE), view);
      }
      //            Rect statusBar = new Rect();
      //            view.getWindowVisibleDisplayFrame(statusBar);
      //            bitmap = Bitmap.createBitmap(bitmap, 0, statusBar.top,
      //                    bitmap.getWidth(), bitmap.getHeight() - statusBar.top,
      //                    null, true);
    } catch (Exception e) {
      bitmap = null;
    }
    return getFilteredImage(bitmap, options);
  }
 @Override
 protected TiBlob doInBackground(Object... params) {
   HashMap options = (HashMap) params[0];
   View view = TiApplication.getAppCurrentActivity().getWindow().getDecorView();
   Bitmap bitmap = null;
   try {
     bitmap = TiUIHelper.viewToBitmap(null, view);
     Rect statusBar = new Rect();
     view.getWindowVisibleDisplayFrame(statusBar);
     bitmap =
         Bitmap.createBitmap(
             bitmap,
             0,
             statusBar.top,
             bitmap.getWidth(),
             bitmap.getHeight() - statusBar.top,
             null,
             true);
   } catch (Exception e) {
     bitmap = null;
   }
   return getFilteredImage(bitmap, options);
 }