Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.62 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Loading resource to bitmap which resource is taken from an nl.siegmann.epublib
  2. Book book = null;
  3.     @Override
  4.     public void onCreate(Bundle savedInstanceState) {
  5.         super.onCreate(savedInstanceState);
  6.         setContentView(R.layout.main);
  7.         ImageView iv = (ImageView)findViewById(R.id.image_test);
  8.  
  9.         try{
  10.             Resource res = bookLoaded().getCoverImage();
  11.             Bitmap bm = BitmapFactory.decodeStream(res.getInputStream());
  12.             iv.setImageBitmap(bm);
  13.         }catch (Exception e) {
  14.             // TODO: handle exception
  15.             e.printStackTrace();
  16.         }
  17.                }
  18. public Book bookLoaded(){
  19.         AssetManager am = getAssets();
  20.         try{
  21.             InputStream is = am.open("Ada Madison - [Sophie Knowles Mystery 01] - The Square Root of Murder (epub).epub");
  22.             book = (new EpubReader()).readEpub(is);
  23.         }catch (Exception e) {
  24.             // TODO: handle exception
  25.             e.printStackTrace();
  26.         }
  27.         return book;
  28.     }
  29.        
  30. try{
  31.             byte[] newData = bookLoaded().getCoverImage().getData();
  32.             Bitmap bmp =BitmapFactory.decodeByteArray(newData, 0, newData.length);
  33.             image_view.setImageBitmap(bmp);
  34.         }catch (Exception e) {
  35.             // TODO: handle exception
  36.             e.printStackTrace();
  37.          }
  38.        
  39. try{
  40.             byte[] newData = bookLoaded().getCoverImage().getData();
  41.             Bitmap bmp =BitmapFactory.decodeByteArray(newData, 0, newData.length);
  42.             image_view.setImageBitmap(bmp);
  43.         }catch (Exception e) {
  44.             // TODO: handle exception
  45.             e.printStackTrace();
  46.          }