在文件中存入多幅图,怎样读出来并显示出来。
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的字节,用什么函数啊谢谢了

解决方案 »

  1.   

    in.read(byte[] buffer, int offset, int length)
    你这个就是fis.read(byte[] buffer, 50, (80-50))
      

  2.   

    OutputStream os=openFileOutput("file.txt",Activity.MODE_PRIVATE);

    Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.huge);
    bitmap.compress(CompressFormat.JPEG, 50,os);
    把图片压缩后存储怎样得到图片的字节大小
    只有根据字节大小才能把文件中的多幅图分辨出来
    不用多个文件存储应该比较方面吧,不然有好几幅图片,得建好几个文件夹