今日项目出现一个bug:
出现代码:
int width, height; height = bmSrc.getHeight(); width = bmSrc.getWidth(); bmpGray = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);// android4.4.2(SM-N9008V),NativeMethod Canvas 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;
安卓复选框对话框:
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)来初始化速率的单位 。
注意VelocityTracker不使用时要回收