
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 1.62 KB | hits: 13 | expires: Never
Loading resource to bitmap which resource is taken from an nl.siegmann.epublib
Book book = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView iv = (ImageView)findViewById(R.id.image_test);
try{
Resource res = bookLoaded().getCoverImage();
Bitmap bm = BitmapFactory.decodeStream(res.getInputStream());
iv.setImageBitmap(bm);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public Book bookLoaded(){
AssetManager am = getAssets();
try{
InputStream is = am.open("Ada Madison - [Sophie Knowles Mystery 01] - The Square Root of Murder (epub).epub");
book = (new EpubReader()).readEpub(is);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return book;
}
try{
byte[] newData = bookLoaded().getCoverImage().getData();
Bitmap bmp =BitmapFactory.decodeByteArray(newData, 0, newData.length);
image_view.setImageBitmap(bmp);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
try{
byte[] newData = bookLoaded().getCoverImage().getData();
Bitmap bmp =BitmapFactory.decodeByteArray(newData, 0, newData.length);
image_view.setImageBitmap(bmp);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}