start_time = System.currentTimeMillis();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap=BitmapFactory.decodeFile(path,options);
options.inSampleSize=calculateSize(options,width,height);
options.inJustDecodeBounds=false;
//整个图像,下采样
bitmap=BitmapFactory.decodeFile(path,options);
//部分图像
Bitmap patch=Bitmap.createBitmap(bitmap, 10, 10, 100, 100);
end_time = System.currentTimeMillis();
Log.v("BitmapTest", "UI time consume:"+(end_time - start_time));
imageView.setImageBitmap(bitmap);
patchView.setImageBitmap(patch);
start_time = System.currentTimeMillis(); String path=Environment.getExternalStorageDirectory().getPath()+File.separator+"image1.jpg"; ImgThread imgThread=new ImgThread(msgHandler,path,width,height); imgThread.start();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap=BitmapFactory.decodeFile(path,options);
options.inSampleSize=calculateSize(options,width,height);
options.inJustDecodeBounds=false;
//整个图像,下采样
bitmap=BitmapFactory.decodeFile(path,options);
//部分图像
Bitmap patch=Bitmap.createBitmap(bitmap, 10, 10, 100, 100);
array=new ArrayList<Bitmap>(2);
array.add(bitmap);
array.add(patch);
//Serializable传递
Bundle bundle=new Bundle();
bundle.putSerializable("img", array);
//Parcelable传递
/*
MyList l=new MyList(Parcel.obtain());
l.array=array;
bundle.putParcelable("img", l);
*/
Message msg= new Message();
msg.what=1;
msg.setData(bundle);
handler.sendMessage(msg);
Bundle bundle=msg.getData();
//Serializable传递
ArrayList<Bitmap> array=(ArrayList<Bitmap>) bundle.getSerializable("img");
//Parcelable传递
//MyList l=(MyList)bundle.getParcelable("img");
//ArrayList<Bitmap> array=l.array;//=(ArrayList<Bitmap>) bundle.getParcelable("img");
Bitmap bitmap=array.get(0);
Bitmap patch=array.get(1);
end_time = System.currentTimeMillis();
Log.v("BitmapTest", "Th time consume:"+(end_time - start_time));
imageView.setImageBitmap(bitmap);
patchView.setImageBitmap(patch);
package com.example.bitmaptest;
import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;
public class MyList implements Parcelable{
public ArrayList array;
public MyList(Parcel in)
{
in.readValue(null);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(array);
}
public static final Parcelable.Creator<MyList> CREATOR = new Parcelable.Creator<MyList>() {
@Override
public MyList createFromParcel(Parcel source) {
return new MyList(source);
}
@Override
public MyList[] newArray(int size) {
return new MyList[size];
}
};
}
//Parcelable传递
MyList l=new MyList(Parcel.obtain());
l.array=array;
bundle.putParcelable("img", l);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有