yuv420sp crop from any startpoint and width and height
来源:互联网 发布:高德导航端口检测工具 编辑:程序博客网 时间:2024/06/05 14:11
做图像处理的时候,经常需要进行相关图像的裁剪,旋转,复制等处理,
前文有一些这方面的文档,但是不适合我的要求,我的要求是:
剪裁一个yuv420sp 的数据,调试了一段时间,现把相关代码分享出来。
当初有一个坑,就是在x_start ,y_start/2的时候写成x_start>>1,y_start>>1 的时候,出现错误,后来改为x_start ,y_start/2 问题就好了。
当然也可以把yBuf,uvBuf 合为一个大buf,这样就是crop 出一个完整的yuv420sp数据,由于我正好需要分开出来y,uv 分量,所以我做了两个buf。
ByteBuffer yBuf; ByteBuffer uvBuf;public void cropYUV420sp(byte[] src,int src_width,int src_height,int x_start,int y_start,int dst_width,int dst_height){ int oldyuvlen = src_width*src_height; yBuf = ByteBuffer.allocateDirect(dst_height*dst_width); yBuf.order(ByteOrder.nativeOrder()).position(0); uvBuf = ByteBuffer.allocateDirect(dst_height*dst_width/2); uvBuf.order(ByteOrder.nativeOrder()).position(0); for(int i=0;i<dst_height;i++) yBuf.put(src,(x_start)+(y_start+i)*src_width,dst_width); for(int i=0;i<dst_height>>1;i++) { uvBuf.put(src,(y_start/2 +i)*src_width+x_start+oldyuvlen,dst_width); } yBuf.position(0); uvBuf.position(0);}
阅读全文
0 0
- yuv420sp crop from any startpoint and width and height
- Set Height and Width Pie Chart
- studyjams notes 1B--width and height
- 得到屏幕的Width And Height
- web-屏幕、浏览器、页面-width and height
- Calculate height and width of GIF/JPG files
- About the Height and Width property of DisplayObject
- Android get layout height and width in a fragment
- CCLabelTTF with fixed width and dynamic height solution
- do you have "has ambiguous scrollable content width and height"
- React-Native 基础(五) Height and Width
- java.lang.IllegalArgumentException: width and height must be > 0
- Validate (Check) dimensions (Height and Width) of Image before Upload using HTML5, JavaScript and jQ
- QML - Control border width and color on any one side of Rectangle element
- Sencha Touch Component's Width And Height/组件的宽度和高度
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决
- Bitmap.createBitmap参数异常之java.lang.IllegalArgumentException: width and height must be > 0
- redis-zset
- 解析Xml
- 如何在开发过程中快速实现页面功能
- 高精度算法
- Android代码通过包名调用系统卸载程序
- yuv420sp crop from any startpoint and width and height
- python IDLE怎么清屏
- 积分系统(8)-编辑公告之界面层
- STL 中队列的使用(queue)
- QListWidget和QTableWidget的使用和属性;QTableWidget和QListWidget样式表的设置及滚动条的样式设置
- sikuli-ide 问题:mismatched input '<EOF>' exception DEDENT return JRegion.observer(self,time)\n
- 希尔排序 堆排序 与 二叉树排序
- thread50
- C++搜索与回溯算法之马走日(遍历问题)