09 2012 档案

摘要:1、算法第一步:从右下到左上遍历图片像素第二步:获取当前像素和 左上点像素,分别取它们RGB的差值第三步:获取三个差值中绝对值最大的一个作为灰度值第四步:将该灰度值加128 ,并且作像素安全处理(即gray = gray>255?255:gray , gray = gray<0 ? 0 : gray)第五步:使用该灰度值创建图片2、实现代码public Bitmap render(Bitmap bitmap) { if (bitmap == null) return null;// bitmap = toGray(bitmap); ... 阅读全文
posted @ 2012-09-28 09:25 lipeil 阅读(696) 评论(0) 推荐(0)
摘要:1、监听广播缺点,因为优先级的原因可能接收不到。代码:public static final String TAG = "ImiChatSMSReceiver"; public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED"; public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(SMS_RECEIVED_ACTION) 阅读全文
posted @ 2012-09-24 18:11 lipeil 阅读(4231) 评论(0) 推荐(0)
摘要:1、算法r = r*128/(g+b +1);g = g*128/(r+b +1);b = b*128/(g+r +1);2、代码实现public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels ,0 , width , 0 , 0 ,... 阅读全文
posted @ 2012-09-21 14:44 lipeil 阅读(308) 评论(0) 推荐(0)
摘要:1、算法r = Math.sqrt((r- rightr)^2 + (r-bottomr)^2)*2g = Math.sqrt((g- rightg)^2 + (g-bottomg)^2)*2b = Math.sqrt((b- rightb)^2 + (b-bottomb)^2)*22、代码实现 public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[]... 阅读全文
posted @ 2012-09-21 11:48 lipeil 阅读(601) 评论(0) 推荐(0)
摘要:1、算法R = |g – b + g + r| * r / 256G = |b – g + b + r| * r / 256;B = |b – g + b + r| * g / 256;然后灰化。2、代码实现 public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap... 阅读全文
posted @ 2012-09-21 11:14 lipeil 阅读(490) 评论(0) 推荐(0)
摘要:float mSize = 0.5f; public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; final int SIZE = 32768; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int ratio = width >height ? height * SIZE /width : width * SIZE/height;//这里有额外*2^15 用于放大比率;之后的比率使用时需要右移15位... 阅读全文
posted @ 2012-09-21 10:43 lipeil 阅读(6775) 评论(0) 推荐(0)
摘要:1、算法将对rgb 值依次做better处理,同时再下一步用到上一步已经处理好的值。 public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels ,0 , width , 0 , 0 , width , height); for... 阅读全文
posted @ 2012-09-20 20:19 lipeil 阅读(654) 评论(0) 推荐(0)
摘要:1、怀旧特效算法:r = 0.393r +0.769g+0.189bg = 0.349r + 0.686g +0.168bb = 0.272r +0.534g +0.131b2、算法的一般实现: public Bitmap render(Bitmap bitmap) { if(bitmap == null)return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPix... 阅读全文
posted @ 2012-09-20 16:08 lipeil 阅读(405) 评论(0) 推荐(0)
摘要:1、支持的视频格式当前,video 元素支持三种视频格式:格式 IE Firefox Opera Chrome SafariOgg No 3.5+ 10.5+ 5.0+ NoMPEG4 9.0+ No No 5.0+ 3.0+WebM No 4.0+ 10.6+ 6.0+ NoOgg = 带有 Theora 视频编码和 Vorbis 音频编码的 Ogg 文件MPEG4 = 带有 H.264 视频编码和 AAC 音频编码的 MPEG 4 文件WebM = 带有 V... 阅读全文
posted @ 2012-09-18 17:47 lipeil 阅读(503) 评论(0) 推荐(0)
摘要:1、获取root权限sudo su2、安装mysql5apt-get install mysql-server mysql-client3、安装apache2apt-get install apache2Apache的默认文档根目录是在Ubuntu上的/var/www目录 ,配置文件是/ etc/apache2/apache2.conf。配置存储在的子目录在/etc/apache2目录。sudo /etc/init.d/apache2 stop 关闭服务器sudo /etc/init.d/apache2 start 启动服务器sudo /etc/init.d/apache2 restart 重 阅读全文
posted @ 2012-09-18 14:58 lipeil 阅读(1315) 评论(0) 推荐(0)
摘要:HashMap :实现map接口;使用hash算法,里面的数据是无序的;并且存储的是键值对;非线程安全;HashSet :实现了Set接口;内部封装了hashmap,故也是无序的;因为实现set接口,存储的是key,value永远为PRESENT;非线程安全; 阅读全文
posted @ 2012-09-07 23:49 lipeil 阅读(4972) 评论(0) 推荐(0)
摘要:join的用法:join是非静态的方法 有线程 threadA 与threadB,同时运行 1、如果在 threadA中调用自身的join方法,则threadA被堵塞,即使threadB结束,threadA也不会解除堵塞。//threadA堵塞threadA,直到threadA结束,发生死锁 2、如 阅读全文
posted @ 2012-09-07 22:53 lipeil 阅读(950) 评论(0) 推荐(1)
摘要:四种launchMode分别是 1、standard 2、singleTop 3、singleTask 4、singleInstancestandard :android 默认的启动模式,不管在task中有没有该activity的实例,都会new 一个新的实例。singleTop:只有该activity的实例在task(stack)顶部,才不同重复创建,否则还是需要创建一个新的activity。(只重用stack|task顶部的activity实例)singleTask:如果task中存在 activity的实例,则直接使用该实例 ,并将之上的其他activity实例清除,使该activity 阅读全文
posted @ 2012-09-07 22:15 lipeil 阅读(251) 评论(0) 推荐(0)
摘要:public static Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmpGrayscale); ... 阅读全文
posted @ 2012-09-01 19:12 lipeil 阅读(1443) 评论(0) 推荐(0)
摘要:ExecutorService pool; android 自身的线程池 public void Init() { pool = Executors.newFixedThreadPool(3); for(int j=0 ; j< 10 ; j++) { Thread thread = new Thread() { public void run() { ... 阅读全文
posted @ 2012-09-01 19:04 lipeil 阅读(7566) 评论(2) 推荐(0)
摘要:以如下布局为例:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Li 阅读全文
posted @ 2012-09-01 17:43 lipeil 阅读(277) 评论(0) 推荐(0)
摘要:第一步:保存apk文件到sdcard或者其他地方第二步:修改apk文件的权限为可执行 ,例如chmod ‘777’ file:String command = "chmod " + permission + " " + path;Runtime runtime = Runtime.getRuntime();runtime.exec(command);第三步:使用Intent 调用安装:Intent intent = new Intent(Intent.ACTION_VIEW);intent.addFlags(Intent.FLAG_ACTIVITY_NE 阅读全文
posted @ 2012-09-01 16:20 lipeil 阅读(13819) 评论(0) 推荐(0)
摘要:android 中可以设置自己添加的字体:比如宋体之类的Typeface typeface=Typeface.createFromAsset(getAssets(),"font/font_"+i+".ttf"); textView.setTypeface(typeface);汉字字体通常都是10M左右,放到apk中相当不划算 - -!,还是用图片代替。 阅读全文
posted @ 2012-09-01 16:15 lipeil 阅读(363) 评论(0) 推荐(1)
摘要:dip或dp,(device independent pixels,设备独立像素),一般为了支持WVGA、HVGA和QVGA使用这个,不依赖像素。 这里要特别注意dip与屏幕密度有关,而屏幕密度又与具体的硬件有关,硬件设置不正确,有可能导致dip不能正常显示。在屏幕密度为160的显示屏上,1dip= 阅读全文
posted @ 2012-09-01 16:09 lipeil 阅读(533) 评论(0) 推荐(0)