WEB开发网      婵犻潧鍊婚弲顐︽偟椤栨稓闄勯柦妯侯槸閻庤霉濠婂骸浜剧紒杈ㄥ笚閹峰懘鎮╅崹顐ゆ殸婵炴垶鎸撮崑鎾趁归悩鐑橆棄闁搞劌瀛╃粋宥夘敃閿濆柊锕傛煙鐎涙ê鐏f繝濠冨灴閹啴宕熼鍡╀紘婵炲濮惧Λ鍕叏閳哄懎绀夋繛鎴濈-楠炪垽鎮归崶褍妲婚柛銊ュ缁傚秹鏁撻敓锟� ---闂佹寧娲╅幏锟�
开发学院手机开发Android 开发 Android 图片放大修改代码 阅读

Android 图片放大修改代码

 2010-09-10 00:57:00 来源:WEB开发网 闂侀潧妫撮幏锟�闂佸憡鍨电换鎰版儍椤掑倵鍋撳☉娆嶄沪缂傚稄鎷�婵犫拃鍛粶闁靛洤娲ㄩ埀顒佺⊕閵囩偟绱為敓锟�闂侀潧妫撮幏锟�  闂佺ǹ绻楀▍鏇㈠极閻愬搫绾ч柕濠忕細閼割亜顪冪€n剙浠ф繛鍫熷灥椤曘儵顢欓悡搴ば�
核心提示:bitmap = BitmapFactory.decodeStream(is);is.close();} catch (IOException e) {e.printStackTrace();}Log.v(tag,bitmap.toString());return bitmap;}public static Drawa

bitmap = BitmapFactory.decodeStream(is);

is.close();

} catch (IOException e) {

e.printStackTrace();

}

Log.v(tag,bitmap.toString());

return bitmap;

}

public static Drawable resizeImage(Bitmap bitmap, int w, int h) {

// load the origial Bitmap

Bitmap BitmapOrg = bitmap;

int width = BitmapOrg.getWidth();

int height = BitmapOrg.getHeight();

int newWidth = w;

int newHeight = h;

Log.v(tag,String.valueOf(width));

Log.v(tag,String.valueOf(height));

Log.v(tag,String.valueOf(newWidth));

Log.v(tag,String.valueOf(newHeight));

// calculate the scale

float scaleWidth = ((float) newWidth) / width;

float scaleHeight = ((float) newHeight) / height;

// create a matrix for the manipulation

Matrix matrix = new Matrix();

// resize the Bitmap

matrix.postScale(scaleWidth, scaleHeight);

// if you want to rotate the Bitmap

// matrix.postRotate(45);

// recreate the new Bitmap

Bitmap resizedBitmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width,

height, matrix, true);

// make a Drawable from Bitmap to allow to set the Bitmap

// to the ImageView, ImageButton or what ever

return new BitmapDrawable(resizedBitmap);

}

}

上一页  1 2 

Tags:Android 图片 放大

编辑录入:coldstar [复制链接] [打 印]
赞助商链接