rlCopyFramebuffer method

Uint8List rlCopyFramebuffer(
  1. num x,
  2. num y,
  3. num width,
  4. num height,
  5. PixelFormat format,
)

Copy framebuffer pixel data to internal buffer

Implementation

Uint8List rlCopyFramebuffer(
  num x,
  num y,
  num width,
  num height,
  PixelFormat format,
) => run(
  () => _debugLabels.rlCopyFramebuffer(x, y, width, height, format),
  () {
    final size = _coreDart.GetPixelDataSize(width, height, format);
    if (size <= 0) {
      throw ArgumentError(
        'rlCopyFramebuffer: invalid pixel data size for '
        '${width}x$height @ $format',
      );
    }

    final pixels = $.Uint8$.Sized(size);

    _flat.rlCopyFramebuffer(
      x.toInt(),
      y.toInt(),
      width.toInt(),
      height.toInt(),
      format.value,
      pixels.cast(),
    );

    return pixels.asCopy(size);
  },
);