編輯:關於android開發
/**
* bitmap 圖片縮放到指定大小
*/
public static Bitmap resizeImage(Bitmap bitmap, int w, int h)
{
Bitmap BitmapOrg = bitmap;
int width = BitmapOrg.getWidth();
int height = BitmapOrg.getHeight();
int newWidth = w;
int newHeight = h;
float scaleWidth = ((float)newWidth) / width;
float scaleHeight = ((float)newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// if you want to rotate the Bitmap
// matrix.postRotate(45);
Bitmap resizedBitmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width, height, matrix, true);
return resizedBitmap;
}
/**
* 把一張圖放到另一張背景圖上。
*/
public static Drawable addbackground4onlyicon(Bitmap b1, Bitmap b2,Context mContext)
{
if (!b1.isMutable())
{
// 設置圖片為背景為透明
b1 = b1.copy(Bitmap.Config.ARGB_8888, true);
}
Paint paint = new Paint();
Canvas canvas = new Canvas(b1);
canvas.drawBitmap(b2, 17.5f, 17.5f, paint);// 疊加新圖b2 (120-85)/2= 17.5
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
return new BitmapDrawable(mContext.getResources(), b1);
}
linux編程之socket
linux編程之socketTCP/IP協議及socket封裝socket編程的基本流程socket連接的建立(3次握手)socket連接的斷開(3次握手)由於TCP連接
Android快樂貪吃蛇游戲實戰項目開發教程-04虛擬方向鍵(三)三角形按鈕效果,android-04
Android快樂貪吃蛇游戲實戰項目開發教程-04虛擬方向鍵(三)三角形按鈕效果,android-04該系列教程概述與目錄:http://www.cnblogs.com/
用Kotlin實現Android定制視圖(KAD 06),kotlinandroid
用Kotlin實現Android定制視圖(KAD 06),kotlinandroid作者:Antonio Leiva 時間:Dec 27, 2016 原文鏈接:https
Android窗口機制分析與UI管理系統,androidui
Android窗口機制分析與UI管理系統,androidui類圖關系 在看Android的窗口機制之前,先看看其主要的類圖關系以及層級之間的依賴與調用關系