I want to add up two InputStream
objects that actually are a splitted .JPG file into one and then use it in a Drawable
to show in ImageView. I googled and found SequenceInputStream
but it didn't work.the code is blow:
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import android.R.drawable;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
public class LoadFromAssetsActivity extends Activity {
ImageView mImage;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_load_from_assets);
mImage = (ImageView)findViewById(R.id.imageView1);
loadDataFromAsset();
}
public void loadDataFromAsset() {
// load image
try {
// get input stream
InputStream ims1 = getAssets().open("1");
InputStream ims2 = getAssets().open("2");
InputStream imsTotal = new SequenceInputStream(ims1, ims2);
// load image as Drawable
Drawable d = Drawable.createFromStream(imsTotal, null);
// set image to ImageView
mImage.setImageDrawable(d);
}
catch(IOException ex) {
return;
}
}
}