-
Notifications
You must be signed in to change notification settings - Fork 53
static_sticker
zanxiaofei edited this page Jun 12, 2017
·
1 revision
金山云短视频SDK提供静态贴纸的功能,支持在编辑部分添加贴纸,并最终生合成到视频中
贴纸提供旋转、缩放、无限叠加等功能
- KSYStickerView贴纸预览控件,提供贴纸的预览、添加、删除功能 (SDK内部提供)
- StickerHelpBoxInfo贴纸辅助区域的画笔,用于提供贴纸辅助区域的删除、旋转按钮及辅助区域绘制Paint
- StickerAdapter贴图列表适配器 (Demo示例)
- 添加预览贴纸控件
在编辑预览的xml中添加KSYStickerView控件来进行贴纸的预览,并需要将该对象设置给SDK内部
//xml中添加控件
<com.ksyun.media.shortvideo.view.KSYStickerView
android:id="@+id/sticker_panel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:visibility="gone"/>
//获取控件实例
mKSYStickerView = (KSYStickerView) findViewById(R.id.sticker_panel);
//设置给SDK内部
mEditKit.addStickerView(mKSYStickerView);
- 添加贴纸
调用KSYStickerView的addSticker(String path, StickerHelpBoxInfo helpInfo)接口用于添加贴纸,示例如下:
//辅助区域信息
if(mStickerHelpBoxInfo == null) {
mStickerHelpBoxInfo = new StickerHelpBoxInfo();
mStickerHelpBoxInfo.deleteBit = mStickerDeleteBitmap; //删除按钮
mStickerHelpBoxInfo.rotateBit = mStickerRotateBitmap; //旋转按钮
//辅助区域画笔
Paint helpBoxPaint = new Paint();
helpBoxPaint.setColor(Color.BLACK);
helpBoxPaint.setStyle(Paint.Style.STROKE);
helpBoxPaint.setAntiAlias(true); //抗锯齿
helpBoxPaint.setStrokeWidth(4); //宽度
mStickerHelpBoxInfo.helpBoxPaint = helpBoxPaint;
}
mKSYStickerView.addSticker(getImageFromAssetsFile(path), mStickerHelpBoxInfo);
- 删除贴纸
- 删除某一张贴纸,只需要按下删除按钮即可,SDK内部会进行删除,不需要额外调用接口
- 删除所有贴纸,可以调用KSYStickerView的removeStickers()接口来完成