You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 7, 2025. It is now read-only.
Could we please have a callback allowing us to modify bitmaps before saving them to the device ?
It can be done by passing an interface and hacking the following method in Spoon
private static void takeScreenshot(File file, final Activity activity, final Callback callback) throws IOException {
View view = activity.getWindow().getDecorView();
final Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
if(Looper.myLooper() == Looper.getMainLooper()) {
drawDecorViewToBitmap(activity, bitmap);
} else {
final CountDownLatch fos = new CountDownLatch(1);
activity.runOnUiThread(new Runnable() {
public void run() {
try {
Spoon2.drawDecorViewToBitmap(activity, bitmap);
} finally {
fos.countDown();
}
}
});
try {
fos.await();
} catch (InterruptedException var10) {
String msg = "Unable to get screenshot " + file.getAbsolutePath();
Log.e("Spoon", msg, var10);
throw new RuntimeException(msg, var10);
}
}
callback.peek(bitmap); // user modifications there
BufferedOutputStream fos1 = null;
try {
fos1 = new BufferedOutputStream(new FileOutputStream(file));
bitmap.compress(CompressFormat.PNG, 100, fos1);
Chmod.chmodPlusR(file);
} finally {
bitmap.recycle();
if(fos1 != null) {
fos1.close();
}
}
}