3.2学习内容:android图片灰度化,VelocityTracker类
来源:互联网 发布:什么是矩阵音响 编辑:程序博客网 时间:2024/04/29 16:27
今日项目出现一个bug:
出现代码:
int width, height;height = bmSrc.getHeight();width = bmSrc.getWidth();bmpGray = Bitmap.createBitmap(width, height,Bitmap.Config.RGB_565);// android4.4.2(SM-N9008V),NativeMethodCanvas c = new Canvas(bmpGray);Paint paint = new Paint();ColorMatrix cm = new ColorMatrix();cm.setSaturation(0);ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);paint.setColorFilter(f);c.drawBitmap(bmSrc, 0, 0, paint);
bmpGray = Bitmap.createBitmap(width, height,Bitmap.Config.RGB_565);// android4.4.2(SM-N9008V),NativeMethod
解决方案:
使用另外一种灰度化方法:
// constant factors final double GS_RED = 0.299; final double GS_GREEN = 0.587; final double GS_BLUE = 0.114; // create output bitmap Bitmap bmOut = Bitmap.createBitmap(bmSrc.getWidth(), bmSrc.getHeight(), bmSrc.getConfig()); // pixel information int A, R, G, B; int pixel; // get image size int width = bmSrc.getWidth(); int height = bmSrc.getHeight(); // scan through every single pixel for(int x = 0; x < width; ++x) { for(int y = 0; y < height; ++y) { // get one pixel color pixel = bmSrc.getPixel(x, y); // retrieve color of all channels A = Color.alpha(pixel); R = Color.red(pixel); G = Color.green(pixel); B = Color.blue(pixel); // take conversion up to one single value R = G = B = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B); // set new pixel color to output bitmap bmOut.setPixel(x, y, Color.argb(A, R, G, B)); } } // return final image return bmOut;
来源:http://zhidao.baidu.com/link?url=qKdqviboKNQdRW2e_1NCJKyDArCd3fqgpthYWUpZd9RxKuWJ_Qdn66wvACJ-gHvdtws7AqWfMnZqtlo96-lLPCfWNeqNGgL0y6pXejrBKPe
安卓复选框对话框:
Builder builder=new android.app.AlertDialog.Builder(this);
//设置对话框的图标
builder.setIcon(R.drawable.header);
//设置对话框的标题
builder.setTitle("复选框对话框");
builder.setMultiChoiceItems(R.array.hobby, flags, new DialogInterface.OnMultiChoiceClickL
android.view.VelocityTracker主要用跟踪触摸屏事件(flinging事件和其他gestures手势事件)的速率。用addMovement(MotionEvent)函数将Motion event加入到VelocityTracker类实例中.你可以使用getXVelocity() 或getXVelocity()获得横向和竖向的速率到速率时,但是使用它们之前请先调用computeCurrentVelocity(int)来初始化速率的单位 。
private VelocityTracker mVelocityTracker;//生命变量
//在onTouchEvent(MotionEvent ev)中
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();//获得VelocityTracker类实例
}
mVelocityTracker.addMovement(ev);//将事件加入到VelocityTracker类实例中
//判断当ev事件是MotionEvent.ACTION_UP时:计算速率
final VelocityTracker velocityTracker = mVelocityTracker;
// 1000 provides pixels per second
velocityTracker.computeCurrentVelocity(1, (float)0.01); //设置maxVelocity值为0.1时,速率大于0.01时,显示的速率都是0.01,速率小于0.01时,显示正常
Log.i("test","velocityTraker"+velocityTracker.getXVelocity());
velocityTracker.computeCurrentVelocity(1000); //设置units的值为1000,意思为一秒时间内运动了多少个像素
Log.i("test","velocityTraker"+velocityTracker.getXVelocity());
注意VelocityTracker不使用时要回收
0 0
- 3.2学习内容:android图片灰度化,VelocityTracker类
- android VelocityTracker类
- android VelocityTracker类
- Android中VelocityTracker类
- Android学习篇章11-VelocityTracker
- Android Scroller和VelocityTracker类
- android图片的灰度化处理
- Android 图片转灰度
- android 改变图片灰度
- android VelocityTracker
- Android VelocityTracker
- Android VelocityTracker
- bmp图片灰度化
- java 图片灰度化
- matlab图片 灰度化
- 【Android Studio】绘制灰度图片
- VelocityTracker类
- VelocityTracker类
- Android初学之Android项目结构
- Java学习笔记25
- 【Unity3D】Unity3D中的C#基本语法知识点①(变量与数组)
- poj3253求切割木板开销最少是多少, 赫夫曼编码
- Duang~ Golang 学习初探
- 3.2学习内容:android图片灰度化,VelocityTracker类
- 图片延迟加载——例子
- git私有远程库的建立与使用
- java BTrace-代码追踪
- STL vector使用
- STL求最长上升子序列
- CodeForces 25C Roads in Berland(图论-最短路径)
- c#基础(四)----运算符
- emacs配置详解及C/C++IDE全功能配置演示(附配置文件)