Class ScreenRecorder

    • Constructor Detail

      • ScreenRecorder

        ScreenRecorder()
    • Method Detail

      • captureScreenshot

         final ByteArray captureScreenshot(View rootView)

        Captures a screenshot of the provided rootView at 1x scale (logical pixels).

        This method renders the view hierarchy into a Bitmap at 1x density (similar to iOS scale = 1.0), applies masking if necessary, compresses the image to a JPEG byte array, and then recycles the Bitmap to free memory.

        Threading: This function MUST be called from the main thread as it performs view operations. CPU-intensive compression happens on a background thread.

        Parameters:
        rootView - The root View to capture.
        Returns:

        A ByteArray containing the compressed JPEG image, or null if capture fails.

      • clearBitmapPool

         final Unit clearBitmapPool()

        Clears the bitmap pool and releases all pooled bitmaps.

        This should be called when screen recording stops to free memory. The pool will be re-initialized automatically on the next screenshot capture.

        Thread-safe: Uses synchronization to prevent race conditions with concurrent screenshot captures or pool initialization.