MGImage.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // MGImage.h
  3. // MGBankCard
  4. //
  5. // Created by 张英堂 on 15/12/11.
  6. // Copyright © 2015年 megvii. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import <CoreMedia/CoreMedia.h>
  11. #import <AVFoundation/AVFoundation.h>
  12. @interface MGImage : NSObject
  13. /**
  14. * 裁剪图片
  15. *
  16. * @param image 原始图片
  17. * @param bounds 裁剪的区域
  18. *
  19. * @return 裁剪后的图片
  20. */
  21. + (UIImage*)croppedImage:(UIImage *)image
  22. rect:(CGRect)bounds;
  23. /**
  24. * 修正图片方向
  25. *
  26. * @param image 原始图片
  27. *
  28. * @return 修正完成的图片
  29. */
  30. + (UIImage*)fixOrientationWithImage:(UIImage *)image;
  31. //+ (UIImage*)fixOrientationWithImageOrientation:(UIImage *)image
  32. // orientation:(UIImageOrientation) orientation;
  33. /**
  34. * 把sampleBuffer转化为图片
  35. *
  36. * @param sampleBuffer sampleBuffer
  37. * @param orientation 图片的方向
  38. *
  39. * @return 转化完成的图片
  40. */
  41. + (UIImage*)imageFromSampleBuffer:(CMSampleBufferRef)sampleBuffer
  42. orientation:(UIImageOrientation) orientation;
  43. //+ (UIImage*)fixOrientationFromSampleBuffer:(CMSampleBufferRef)sampleBuffer
  44. // orientation:(UIImageOrientation)orientation;
  45. /*视频角度转化为数值*/
  46. + (CGFloat)angleOffsetFromPortraitOrientationToOrientation:(AVCaptureVideoOrientation)orientation;
  47. @end