addTextWatermarkUint8List method

  1. @override
Future<Uint8List?> addTextWatermarkUint8List(
  1. String filePath,
  2. Uint8List? bytes,
  3. String text,
  4. int x,
  5. int y,
  6. int textSize,
  7. bool isNeedRotateToPortrait,
  8. Color color,
  9. Color? backgroundTextColor,
  10. int? backgroundTextPaddingTop,
  11. int? backgroundTextPaddingBottom,
  12. int? backgroundTextPaddingLeft,
  13. int? backgroundTextPaddingRight,
)
override

Adds a text watermark to the image at the specified location with the given parameters.

Returns a Uint8List representing the watermarked image.

Implementation

@override
Future<Uint8List?> addTextWatermarkUint8List(
  String filePath,
  Uint8List? bytes,
  String text,
  int x,
  int y,
  int textSize,
  bool isNeedRotateToPortrait,
  Color color,
  Color? backgroundTextColor,
  int? backgroundTextPaddingTop,
  int? backgroundTextPaddingBottom,
  int? backgroundTextPaddingLeft,
  int? backgroundTextPaddingRight,
) async {
  final result = await watermarkImageChannel.invokeMethod<String?>(
    'addTextWatermark',
    {
      'text': text,
      'filePath': filePath,
      'x': x,
      'y': y,
      'textSize': textSize,
      'color': color.value.toInt(),
      'backgroundTextColor': backgroundTextColor?.value.toInt(),
      'quality': 100,
      'backgroundTextPaddingTop': backgroundTextPaddingTop,
      'backgroundTextPaddingBottom': backgroundTextPaddingBottom,
      'backgroundTextPaddingLeft': backgroundTextPaddingLeft,
      'backgroundTextPaddingRight': backgroundTextPaddingRight,
      'isNeedRotate': isNeedRotateToPortrait,
      'imageFormat': ImageFormat.png.name,
    },
  );
  if (result != null) {
    final resultBytes = await File(result).readAsBytes();
    return resultBytes;
  } else {
    return null;
  }
}