项目作者: KernHu

项目描述 :
Stamper is a tool for stamping a pattern into a picture,it likes a watermark. Stamper是一个给图片打水印的工具,支持图片水印和文字水印,水印位置可以任意调节。
高级语言: Java
项目地址: git://github.com/KernHu/Stamper.git
创建时间: 2018-07-04T13:20:40Z
项目社区:https://github.com/KernHu/Stamper

开源协议:

下载


Stamper

Stamper is a tool for stamping a pattern into a picture,it likes a watermark.

Stamper是一个给图片打水印的工具,支持图片水印和文字水印,水印位置可以任意调节。


I: How to use Stamper.

1.use it stamp a text;

  1. Bitmap bitmap3 = BitmapFactory.decodeResource(getResources(), R.drawable.sample_plot_3);
  2. Stamper.with()
  3. .setLabel("National Geography")
  4. .setLabelColor(getResources().getColor(R.color.theme))//Color.rgb(255, 60, 70)
  5. .setLabelSize(60)
  6. .setMasterBitmap(bitmap3)
  7. .setStampType(StampType.TEXT)
  8. .setStampTextCoordinate(new StampCoordinate(0, 0))
  9. .setStampWatcher(mStampWatcher)
  10. .setRequestId(1001)
  11. .build();

2.use it stamp a image;

  1. Bitmap bitmap4 = BitmapFactory.decodeResource(getResources(), R.drawable.sample_plot_4);
  2. Bitmap watermark = BitmapFactory.decodeResource(getResources(), R.drawable.ic_watermark);
  3. int x = StampUtils.getImageWidthAndHeight(bitmap4)[0] - StampUtils.getImageWidthAndHeight(watermark)[0];
  4. int y = StampUtils.getImageWidthAndHeight(bitmap4)[1] - StampUtils.getImageWidthAndHeight(watermark)[1];
  5. Stamper.with()
  6. .setMasterBitmap(bitmap4)
  7. .setWatermark(watermark)
  8. .setStampType(StampType.IMAGE)
  9. .setStampImageCoordinate(new StampCoordinate(x, y))
  10. .setStampWatcher(mStampWatcher)
  11. .setRequestId(1002)
  12. .build();

3.the callback

  1. StampWatcher mStampWatcher = new StampWatcher() {
  2. @Override
  3. protected void onSuccess(Bitmap bitmap, int requestId) {
  4. super.onSuccess(bitmap, requestId);
  5. switch (requestId) {
  6. case 1001:
  7. //the result of text stamper
  8. break;
  9. case 1002:
  10. //the result of image stamper
  11. break;
  12. }
  13. }
  14. @Override
  15. protected void onError(String error, int requestId) {
  16. super.onError(error, requestId);
  17. switch (requestId) {
  18. case 1001://
  19. break;
  20. case 1002://
  21. break;
  22. }
  23. }
  24. };

II: Add Stamper to your project

Step 1. Add the JitPack repository to your build file; Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Step 2. Add the dependency

  1. dependencies {
  2. implementation 'com.github.kernhu:stamper:Tag'
  3. }

III: Contact me

Email: vsky580@gmail.com
Facebook: https://www.facebook.com/kern.hu.580
QQ群:43447852

I’m kern….

If it helps you,please give me a star.如果有帮助到你,请给我一个小星星。