在文件中存入多幅图,怎样读出来并显示出来。
OutputStream os=openFileOutput("file.txt",Activity.MODE_PRIVATE);
写入三幅图片
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.huge);
bitmap.compress(CompressFormat.JPEG, 50,os);
bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.huge);
bitmap.compress(CompressFormat.JPEG, 50, os);
bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.untitled);
bitmap.compress(CompressFormat.JPEG, 50, os);
os.close();
读取图片
InputStream fis=null;
fis= openFileInput("file.txt");
LinearLayout layout=(LinearLayout)findViewById(R.id.layout01);
ImageView image=new ImageView(this);
int id=10;
image.setId(id);
image.setImageDrawable(Drawable.createFromStream(fis, "file.txt"))
只显示第一幅图,怎样都显示出来
怎样读取文件中特定长度得字节流,例如文件中有100个字节,想读取第50到80的字节,用什么函数啊谢谢了
OutputStream os=openFileOutput("file.txt",Activity.MODE_PRIVATE);
写入三幅图片
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.huge);
bitmap.compress(CompressFormat.JPEG, 50,os);
bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.huge);
bitmap.compress(CompressFormat.JPEG, 50, os);
bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.untitled);
bitmap.compress(CompressFormat.JPEG, 50, os);
os.close();
读取图片
InputStream fis=null;
fis= openFileInput("file.txt");
LinearLayout layout=(LinearLayout)findViewById(R.id.layout01);
ImageView image=new ImageView(this);
int id=10;
image.setId(id);
image.setImageDrawable(Drawable.createFromStream(fis, "file.txt"))
只显示第一幅图,怎样都显示出来
怎样读取文件中特定长度得字节流,例如文件中有100个字节,想读取第50到80的字节,用什么函数啊谢谢了
解决方案 »
- 高手请帮忙解决Stopping ADB server failed (code -1).这个问题
- android屏幕录像原理
- Android 程序出错 出现main.out.xml
- Kernel panic - not syncing: out of memory. panic_on_oom is selected 求指导
- 请教关于触摸屏的事件流处理
- RelativeLayout布局应用动画后相对定位无效
- 从sd卡安装证书
- 移位 、按位或 操作 ???
- phonegap跨域的问题
- Android studio启动模拟器出现keeping shopping怎么办
- ListView点击某个Item后,如何显示出SQLite数据库的表中对应的那一条记录的主键ID?
- 为什么每次都从主界面开始
你这个就是fis.read(byte[] buffer, 50, (80-50))
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.huge);
bitmap.compress(CompressFormat.JPEG, 50,os);
把图片压缩后存储怎样得到图片的字节大小
只有根据字节大小才能把文件中的多幅图分辨出来
不用多个文件存储应该比较方面吧,不然有好几幅图片,得建好几个文件夹