80,490
社区成员
发帖
与我相关
我的任务
分享
1.
2.private Bitmap getImageFromAssetFile(String fileName,int how){
3.Bitmap image = null ;
4.try {
5.AssetManager am = game.getAssets();
6.InputStream is = am.open(fileName);
7.image = BitmapFactory.decodeStream(is);
8.is.close();
9.}catch (Exception e){
10.}
11.return zoomImage(image,how);
12.}
13.public Bitmap zoomImage(Bitmap bgimage,int how) {
14.int bmpwidth = bgimage.getWidth();
15.int bmpheight = bgimage.getHeight();
16.float scaleWidth=0;
17.float scaleHeight=0;
18.Matrix matrix = new Matrix();
19.if(how==0){
20.scaleWidth = ((float) width) / bmpwidth;
21.scaleHeight = ((float) height) / bmpheight;
22.}else{
23.scaleWidth=Math.min(width,height)/bmpwidth;
24.scaleHeight=Math.min(width, height)/bmpheight;
25.}
26.private Bitmap getImageFromAssetFile(String fileName,int how){
27.Bitmap image = null ;
28.try {
29.AssetManager am = game.getAssets();
30.InputStream is = am.open(fileName);
31.image = BitmapFactory.decodeStream(is);
32.is.close();
33.}catch (Exception e){
34.}
35.return zoomImage(image,how);
36.}
37.public Bitmap zoomImage(Bitmap bgimage,int how) {
38.int bmpwidth = bgimage.getWidth();
39.int bmpheight = bgimage.getHeight();
40.float scaleWidth=0;
41.float scaleHeight=0;
42.Matrix matrix = new Matrix();
43.if(how==0){
44.scaleWidth = ((float) width) / bmpwidth;
45.scaleHeight = ((float) height) / bmpheight;
46.}else{
47.scaleWidth=Math.min(width,height)/bmpwidth;
48.scaleHeight=Math.min(width, height)/bmpheight;
49.}