Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FrameCapture

Utility for capturing images directly from any framebuffer. This enables taking a screenshot bigger than the used canvas. Supports capturing of only part of the framebuffer. The resulting image can be transformed to a data URL. The data URL can then be used to embed the image inline in documents or to download it.

controller.postFrameEvent$.pipe(rxjs.operators.first()).subscribe(() => {
    const img = gloperate.FrameCapture.capture(renderer._defaultFBO);
    const data = gloperate.FrameCapture.createDataURL(img, 'image/png');
    console.log(data);
})

Hierarchy

  • FrameCapture

Index

Constructors

constructor

Methods

Static capture

  • Captures (part of) the given attachment of a framebuffer. The format of the underlying texture has to be gl.RGBA and the type has to be either gl.UNSIGNED_BYTE, gl.HALF_FLOAT or gl.FLOAT.

    Parameters

    • framebuffer: DefaultFramebuffer | Framebuffer

      Framebuffer to capture.

    • Optional attachment: number

      Optional attachment to capture from. Is ignored for the default framebuffer.

    • Optional rect: Rect

      Optional part of the framebuffer to capture.

    Returns ImageData

    • The captured image.

Static Protected captureDefaultFramebuffer

  • captureDefaultFramebuffer(framebuffer: Framebuffer, rect: Rect, buffer: Uint8Array): void
  • Captures the gl.BACK buffer of the default framebuffer and writes it into the given framebuffer. Sets the color buffer source for the default framebuffer to gl.BACK.

    Parameters

    • framebuffer: Framebuffer
    • rect: Rect

      Part of the framebuffer to capture.

    • buffer: Uint8Array

      Buffer to write the data into.

    Returns void

Static Protected captureFramebuffer

  • captureFramebuffer(framebuffer: Framebuffer, attachment: number, rect: Rect, buffer: Uint8Array): void
  • Captures the given attachment of the given framebuffer. Sets the color buffer source to the given attachment.

    Parameters

    • framebuffer: Framebuffer

      Framebuffer to capture.

    • attachment: number

      Attachment to capture.

    • rect: Rect

      Part of the framebuffer to capture.

    • buffer: Uint8Array

      Buffer to write the data into.

    Returns void

Static createDataURL

  • createDataURL(imageData: ImageData, type?: string, quality?: number): string
  • Creates a data URL for the given image. The data will be encoded according to type. The type defaults to png, if no type is given. Quality can be only set for types using lossy compression. The default quality is 0.92.

    Parameters

    • imageData: ImageData

      Image to create the data URL for.

    • Optional type: string

      Optional format used for encoding.

    • Optional quality: number

      Optional quality used for lossy compression.

    Returns string

Static flipImageDataVertically

  • flipImageDataVertically(imageData: ImageData): void
  • Flips the given image data vertically.

    Parameters

    • imageData: ImageData

      Image data to flip.

    Returns void