compositeOver static method

void compositeOver(
  1. RgbaImage dst,
  2. RgbaImage overlay
)

Alpha-composite overlay over dst in place (must be same size).

Implementation

static void compositeOver(RgbaImage dst, RgbaImage overlay) {
  assert(dst.width == overlay.width && dst.height == overlay.height);
  final dstBuf = calloc<Uint8>(dst.bytes.length);
  final ovlBuf = calloc<Uint8>(overlay.bytes.length);
  try {
    dstBuf.asTypedList(dst.bytes.length).setAll(0, dst.bytes);
    ovlBuf.asTypedList(overlay.bytes.length).setAll(0, overlay.bytes);
    _composite(dstBuf, ovlBuf, dst.width, dst.height);
    dst.bytes.setAll(0, dstBuf.asTypedList(dst.bytes.length));
  } finally {
    calloc.free(dstBuf);
    calloc.free(ovlBuf);
  }
}