2010年11月29日 星期一

G1 USB HOST

改造G1使其擁有USB HOST
1. 取得手機root權限
2. 刷rom,取得新版fastboot1.3
(在此,我是使用國外論壇釋出的「CyanodenMod-6.0.0-DS」,Ver:2.2,build number:FRF91)
3. 刷經修改過的zImage(root@ubuntu)
4. 安裝手機終端機
5. 掛載usb驅動模組 insmod usbcore.ko , insmod ehci-hcd.ko
6. 掛載輸入驅動模組 insmod usbhid.ko

插上外接電源的usb hub的鍵盤

2010年11月2日 星期二

Android drawable 轉 bitmap

Bitmap drawableToBitmap(Drawable drawable) {
 Bitmap.Config mConfig;
 if(drawable.getOpacity() != PixelFormat.OPAQUE){
  mConfig=Bitmap.Config.ARGB_8888;
 }else{
  mConfig=Bitmap.Config.RGB_565; 
 }
 Bitmap bitmap = Bitmap.createBitmap( drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),  mConfig);
 Canvas canvas = new Canvas(bitmap);
 drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
 drawable.draw(canvas);
 return bitmap;
}


或者你也可以這樣:)

((BitmapDrawable)res.getDrawable(R.drawable.youricon)).getBitmap();

Android bitmap轉drawable

要怎麼把bitmap轉成drawable呢?


Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a01);
Drawable mDrawable = new BitmapDrawable(mBitmap);