Fastest Way of Loading a Bitmap into Bytearray?

Problems with Canvas, OpenGL, etc...

Fastest Way of Loading a Bitmap into Bytearray?

Postby ikaruga3333 » Sat Jun 04, 2011 12:57 pm

As per this link:

http://java.sun.com/developer/technical ... erfTuning/

The fastest way of loading a file is to do the buffering yourself (i.e., *don't* use BufferedInputStream).
So this is what I have to load a bitmap from a file---load into a bytearray and then load to a bitmap:

Code: Select all
       Bitmap bitmap = null, tbitmap = null;
       FileInputStream fis = null;
       try {
      int len = (int)(new File( VideoLiveWallpaper.folder+"/"
                  +VideoLiveWallpaper.
                  imageList[ilen])
            .length());
      fis =
          new FileInputStream(
               VideoLiveWallpaper.folder+"/"
               +VideoLiveWallpaper.
               imageList[ilen++]
               );
      byte buf[] = new byte[len];
      fis.read(buf);
      tbitmap = BitmapFactory.
          decodeByteArray(buf,0,len);
      bitmap = Bitmap.createScaledBitmap(tbitmap,128,128,false);


Unforunately, it doesn't work. I get a NULL bitmap. How can I fix this? (Note "folder" and "imageList" variables have been properly defined and the bitmap exists).
ikaruga3333
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 04, 2011 12:47 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 5 guests