示例#1
0
    public void processingFinished() {
      try {
        Bitmap result = (Bitmap) processing.get();

        // generate filename
        byte[] hashBytes = ByteBuffer.allocate(4).putInt(result.hashCode()).array();
        processed =
            Uri.parse(
                "/sdcard/Download/"
                    + Base64.encodeToString(hashBytes, Base64.URL_SAFE).trim()
                    + ".png");

        // save to file
        FileOutputStream out = null;
        try {
          out = new FileOutputStream(processed.getPath());
          result.compress(Bitmap.CompressFormat.PNG, 90, out);
          Log.d(TAG, "saved to " + processed);
        } catch (Exception e) {
          Log.e(TAG, Log.getStackTraceString(e));
        } finally {
          try {
            out.close();
          } catch (Throwable ignore) {
          }
        }

        double sx = noteList.getWidth();
        double sy = (noteList.getWidth() / result.getWidth()) * result.getHeight();
        interestingThumbnail(Bitmap.createScaledBitmap(result, (int) sx, (int) sy, false));
      } catch (Exception e) {
        Log.d(TAG, Log.getStackTraceString(e));
      }
    }
示例#2
0
 public boolean isReady() {
   return processing.isDone();
 }