Class GeckoDisplay.ScreenshotBuilder

Object
org.mozilla.geckoview.GeckoDisplay.ScreenshotBuilder
Enclosing class:
GeckoDisplay

public static final class GeckoDisplay.ScreenshotBuilder extends Object
Builder to construct screenshot requests.
  • Method Details

    • source

      @AnyThread @NonNull public GeckoDisplay.ScreenshotBuilder source(int x, int y, int width, int height)
      The screenshot will be of a region instead of the entire screen
      Parameters:
      x - Left most pixel of the source region.
      y - Top most pixel of the source region.
      width - Width of the source region in screen pixels
      height - Height of the source region in screen pixels
      Returns:
      The builder
    • source

      @AnyThread @NonNull public GeckoDisplay.ScreenshotBuilder source(@NonNull Rect source)
      The screenshot will be of a region instead of the entire screen
      Parameters:
      source - Region of the screen to capture in screen pixels
      Returns:
      The builder
    • aspectPreservingSize

      @AnyThread @NonNull public GeckoDisplay.ScreenshotBuilder aspectPreservingSize(int width)
      The width of the bitmap to create when taking the screenshot. The height will be calculated to match the aspect ratio of the source as closely as possible. The source screenshot will be scaled into the resulting Bitmap.
      Parameters:
      width - of the result Bitmap in screen pixels.
      Returns:
      The builder
      Throws:
      IllegalStateException - if the size has already been set in some other way.
    • scale

      @AnyThread @NonNull public GeckoDisplay.ScreenshotBuilder scale(float scale)
      The scale of the bitmap relative to the source. The height and width of the output bitmap will be within one pixel of this multiple of the source dimensions. The source screenshot will be scaled into the resulting Bitmap.
      Parameters:
      scale - of the result Bitmap relative to the source.
      Returns:
      The builder
      Throws:
      IllegalStateException - if the size has already been set in some other way.
    • size

      @AnyThread @NonNull public GeckoDisplay.ScreenshotBuilder size(int width, int height)
      Size of the bitmap to create when taking the screenshot. The source screenshot will be scaled into the resulting Bitmap
      Parameters:
      width - of the result Bitmap in screen pixels.
      height - of the result Bitmap in screen pixels.
      Returns:
      The builder
      Throws:
      IllegalStateException - if the size has already been set in some other way.
    • bitmap

      @AnyThread @NonNull public GeckoDisplay.ScreenshotBuilder bitmap(@Nullable Bitmap bitmap)
      Instead of creating a new Bitmap for the result, the builder will use the passed Bitmap.
      Parameters:
      bitmap - The Bitmap to use in the result.
      Returns:
      The builder.
      Throws:
      IllegalStateException - if the size has already been set in some other way.
    • capture

      @UiThread @NonNull public GeckoResult<Bitmap> capture()
      Request a Bitmap of the requested portion of the web page currently being rendered using any parameters specified with the builder.

      This function must be called on the UI thread.

      Returns:
      A GeckoResult that completes with a Bitmap containing the pixels and size information of the requested portion of the visible web page, or returns a failure GeckoResult including the reason why in an Exception