KSYGPUPicMixer.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // KSYGPUPipBlendFilter.h
  3. // GPUImage
  4. //
  5. // Created by pengbin on 16/8/26.
  6. // Copyright © 2016年 ksyun. All rights reserved.
  7. #import <GPUImage/GPUImage.h>
  8. /** 图像混合filter
  9. * 将多个图层的内容进行叠加
  10. * 每个图层有index, [0~n]
  11. * 叠加顺序为0在最下层, index 越大在更上层
  12. * 可以每个图层分别指定位置和大小
  13. * 可以每个图层分别制定透明度
  14. * 可以动态交换图层
  15. * 可以动态刷新图层内容(支持视频)
  16. * 输出的刷新率 与 masterLayer 保持一致
  17. */
  18. @interface KSYGPUPicMixer : GPUImageFilter {
  19. };
  20. /**
  21. @abstract 初始化
  22. @discussion 输出大小等于主要图层的大小
  23. */
  24. - (id)init;
  25. /**
  26. @abstract 初始化,并制定输出图像的大小
  27. @param sz 输出图像的大小
  28. */
  29. - (id)initWithOutputSize:(CGSize)sz;
  30. /**
  31. @abstract 设置主要图层 (默认为0)
  32. @discussion 主要图层一般为视频图层, 当主要图层的输入刷新时, 输出才刷新
  33. */
  34. @property (nonatomic, assign) NSUInteger masterLayer;
  35. /**
  36. @abstract 设置图层的位置和大小 (单位为: 像素值 或者百分比)
  37. @param rect 大小和位置
  38. @param idx 图层的索引
  39. @discussion 缩放变形到对应的位置, 数值有如下两种表示方式
  40. - 像素值:rect中宽度或高度的值必须大于1.0, 则认为是像素值
  41. - 百分比:rect中宽度或高度的值必须小于等于1.0, 则认为是对应输出图像大小的百分比
  42. @discussion 保持宽高比的设置方法
  43. - 宽为0, 则按照高度和输入图像的宽高比计算出宽度
  44. - 高为0, 则按照宽度和输入图像的宽高比计算出高度
  45. @discussion 左上角的位置如果为非负值,则和宽高一样;如果为负数, 则自动居中放置
  46. */
  47. -(void)setPicRect: (CGRect) rect
  48. ofLayer: (NSInteger) idx;
  49. /**
  50. @abstract 获取图层的位置和大小 (单位为: 像素值 或者百分比)
  51. @param idx 图层的索引
  52. @return 位置和大小
  53. */
  54. -(CGRect) getPicRectOfLayer:(NSInteger) idx;
  55. /**
  56. @abstract 设置图层的透明度 (默认为1.0)
  57. @param alpha 透明度(0~1.0), 0为全透明
  58. @param idx 图层的索引
  59. */
  60. -(void)setPicAlpha: (CGFloat) alpha
  61. ofLayer: (NSInteger) idx;
  62. /**
  63. @abstract 获取图层的透明度
  64. @param idx 图层的索引
  65. @return 透明度
  66. */
  67. -(CGFloat) getPicAlphaOfLayer:(NSInteger) idx;
  68. /**
  69. @abstract 设置图层的旋转 (默认为norotation)
  70. @param rotation 透明度(0~1.0), 0为全透明
  71. @param idx 图层的索引
  72. @discussion 可用于设置镜像 (kGPUImageFlipHorizonal)
  73. */
  74. -(void)setPicRotation: (GPUImageRotationMode) rotation
  75. ofLayer: (NSInteger) idx;
  76. /**
  77. @abstract 获取图层的旋转模式
  78. @param idx 图层的索引
  79. @return 旋转模式
  80. */
  81. -(GPUImageRotationMode) getPicRotationOfLayer:(NSInteger) idx;
  82. /**
  83. @abstract 清除特定图层的画面内容
  84. @param index 指定被清除的图层
  85. @discussion 比如切换不同的视频内容时,避免出现黑色背景
  86. */
  87. -(void)clearPicOfLayer:(NSInteger) index;
  88. /**
  89. @abstract 刷新前是否清除画布 (默认 YES)
  90. @discussion 清除画布就是将画布的每个像素恢复为背景颜色
  91. @discussion 当存在覆盖整个画布的不透明图层时, 可以将本属性设为NO, 可以节省部分计算资源
  92. */
  93. @property (nonatomic, assign) BOOL clearCanvasBeforeDraw;
  94. @end