From 4550dc0175ec3c5eabb4f564ecf25024bc9418c2 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Sun, 14 Jul 2019 20:35:57 -0300 Subject: [PATCH] Add real documentation --- .../2019-07-14-watermarks-and-overlays.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/docs/_posts/2019-07-14-watermarks-and-overlays.md b/docs/_posts/2019-07-14-watermarks-and-overlays.md index c2079f4d..527c46a2 100644 --- a/docs/_posts/2019-07-14-watermarks-and-overlays.md +++ b/docs/_posts/2019-07-14-watermarks-and-overlays.md @@ -8,3 +8,66 @@ order: 10 date: 2019-07-14 20:14:31 disqus: 1 --- + +CameraView offers a simple yet powerful framework for watermarks and overlays of any kind. +These overlays can be shown on the live camera preview, plus they appear on the media results +taken with `takePictureSnapshot()` or `takeVideoSnapshot()`. + +### Simple Usage + +```xml + + + + + + + + +``` + +As you can see, the overlay system is View-based - each overlay is just a real `View` attached +into the hierarchy. This is a powerful and creative tool. You can, for instance, retrieve the +overlay with `findViewById` and: + +- Animate it! +- Change its visibility +- Change its position or appearance +- Do so while video is being recorded + + Any changes in the overlay appearance will be recorded in real-time in the picture snapshot + or video snapshot that you are capturing. + + As you can see in the example, you can also selectively choose, for each overlay, whether it + will draw on the preview (`layout_drawOnPreview`), on picture snapshots (`layout_drawOnPreview`), + on video snapshots (`layout_drawOnPreview`). + +### Advanced Usage + +If you need to change these flags at runtime, you should cast the overlay `LayoutParams` as follows: + +```java +// Cast to OverlayLayout.LayoutParams +View overlay = findViewById(R.id.watermark); +OverlayLayout.LayoutParams params = (OverlayLayout.LayoutParams) overlay.getLayoutParams(); + +// Perform changes +params.drawOnPreview = true; // draw on preview +params.drawOnPreview = false; // do not draw on preview +params.drawOnPictureSnapshot = true; // draw on picture snapshots +params.drawOnPictureSnapshot = false; // do not draw on picture snapshots +params.drawOnVideoSnapshot = true; // draw on video snapshots +params.drawOnVideoSnapshot = false; // do not draw on video snapshots + +// When done, apply +overlay.setLayoutParams(params); +```