title: Fast way to load bitmap and make a texture in Android
body: <p>I'm trying to make a kind of photo viewer with OpenGL ES in Android.</p>
  
  <p>In my app, basically when I click a button then get entire photo paths list in sdcard, make a bitmap from a photo and set texture as this bitmap then draw it just in simple quads. But this is quite slow and even the GL view freezes when it is working</p>
  
  <p>making texture should work in GLthread so I set Listener and use <code>queueEvent()</code></p>
  
  <p>the code snippets like this:</p>
  
  <pre><code>public void setTexture(Context context, final String string) {
  Bitmap bitmap = null; 
  try {
      Uri uri = Uri.fromFile(new File(string));
      bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
  } catch (FileNotFoundException e) {
      e.printStackTrace();
  }
  // upload texture by bitmap
  GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);
  GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
  bitmap.recycle();
  }
  
  
  queueEvent(new Runnable() {
                 @Override
                 public void run() {
                     for (int i = 1; i &lt; photos.size() - 1; i++) {
                         try {
                             exifInterface = new ExifInterface(photoList.get(i));
                                 } catch (IOException e) {
                                     e.printStackTrace();
                                 }
                                 String orientation = exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION);
                                 Log.d(TAG, "photoOrientation: " + orientation);
                                 photos.get(i).setOrientation(Integer.parseInt(orientation));
                                 photos.get(i).setTexture(mContext, photoList.get(i));
                             }
                         }
                     });
  </code></pre>
  
  <p>When I check the time, the most time consuming work is <code>decodeStream()</code> So How can I improve it? Is there any way more efficient way to upload bitmap to texture? or At least How can I avoid freezing GLView?</p>