在文件中存入多幅图,怎样读出来并显示出来。
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的字节,用什么函数啊谢谢了
解决方案 »
- 添加zh_HK,但是没办法在语言选择列表显示出来
- 怎样给android系统添加个property
- android的操作系统能不能设置用户权限?
- 新手提问SVN与JAVA ANDROID的开发
- 为什么输入框中不可以输入文字数字等信息
- adb logcat 如何只打印某个应用相关的应用
- 新人请教:现在大家用Android Studio Or Android SDK?
- listView onTouchEvent中如何到item
- Android 如何解析json对象
- 想问一下 ,现在大家做android开发 AS升级到3.3了吗
- 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);
把图片压缩后存储怎样得到图片的字节大小
只有根据字节大小才能把文件中的多幅图分辨出来
不用多个文件存储应该比较方面吧,不然有好几幅图片,得建好几个文件夹